From 5d37f4bad7edce31e0e545b988daf78c1d80fdfe Mon Sep 17 00:00:00 2001
From: heikki <Unknown>
Date: Mon, 7 Aug 2006 15:23:32 +0000
Subject: [PATCH] Fix Bug #20493 : we must prepare prebuilt->trx to point to
 the trx of this thd before using it

---
 handler/ha_innodb.cc | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/handler/ha_innodb.cc b/handler/ha_innodb.cc
index e9c17bd5e49..5d1e2ac03d1 100644
--- a/handler/ha_innodb.cc
+++ b/handler/ha_innodb.cc
@@ -6980,10 +6980,11 @@ ha_innobase::innobase_read_and_init_auto_inc(
 	int		error;
 
 	ut_a(prebuilt);
-	ut_a(prebuilt->trx ==
-		(trx_t*) current_thd->ha_data[innobase_hton.slot]);
 	ut_a(prebuilt->table);
 
+	/* Prepare prebuilt->trx in the table handle */
+	update_thd(current_thd);
+
 	if (prebuilt->trx->conc_state == TRX_NOT_STARTED) {
 		trx_was_not_started = TRUE;
 	}
@@ -7118,6 +7119,9 @@ void ha_innobase::get_auto_increment(
 	longlong	nr;
 	int		error;
 
+	/* Prepare prebuilt->trx in the table handle */
+	update_thd(current_thd);
+
 	error = innobase_read_and_init_auto_inc(&nr);
 
 	if (error) {