List:Internals« Previous MessageNext Message »
From:Heikki Tuuri Date:April 5 2005 4:56pm
Subject:bk commit into 5.0 tree (heikki:1.1880) BUG#8650
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of heikki. When heikki does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.1880 05/04/05 17:56:40 heikki@stripped +2 -0
  handler.cc, ha_innodb.cc:
    Fix Bug #8650 : InnoDB does not rollback SQL statement at an error

  sql/handler.cc
    1.157 05/04/05 17:55:15 heikki@stripped +3 -3
    Fix Bug #8650 : InnoDB does not rollback SQL statement at an error

  sql/ha_innodb.cc
    1.186 05/04/05 17:55:14 heikki@stripped +40 -16
    Fix Bug #8650 : InnoDB does not rollback SQL statement at an error

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	heikki
# Host:	hundin.mysql.fi
# Root:	/home/heikki/mysql-5.0

--- 1.156/sql/handler.cc	Tue Apr  5 14:23:03 2005
+++ 1.157/sql/handler.cc	Tue Apr  5 17:55:15 2005
@@ -520,14 +520,14 @@
   else
     trans= &thd->transaction.stmt;
 
-#ifndef DBUG_OFF
   handlerton **ht=trans->ht;
   while (*ht)
   {
-    DBUG_ASSERT(*ht != ht_arg);
+    if (*ht == ht_arg)
+      DBUG_VOID_RETURN;  /* already registered, return */
     ht++;
   }
-#endif
+
   trans->ht[trans->nht++]=ht_arg;
   trans->no_2pc|=(ht_arg->prepare==0);
   if (thd->transaction.xid.is_null())

--- 1.185/sql/ha_innodb.cc	Mon Apr  4 20:29:30 2005
+++ 1.186/sql/ha_innodb.cc	Tue Apr  5 17:55:14 2005
@@ -748,17 +748,37 @@
 }
 
 /*************************************************************************
-Registers the InnoDB transaction in MySQL, to receive commit/rollback
-events. This function must be called every time InnoDB starts a
-transaction internally. */
-static
+Registers that InnoDB takes part in an SQL statement, so that MySQL knows to
+roll back the statement if the statement results in an error. This MUST be
+called for every SQL statement that may be rolled back by MySQL. Calling this
+several times to register the same statement is allowed, too. */
+inline
 void
-register_trans(
-/*===========*/
-	THD*	thd)	/* in: thd to use the handle */
+innobase_register_stmt(
+/*===================*/
+	THD*	thd)	/* in: MySQL thd (connection) object */
 {
-        /* Register the start of the statement */
+        /* Register the statement */
         trans_register_ha(thd, FALSE, &innobase_hton);
+}
+
+/*************************************************************************
+Registers an InnoDB transaction in MySQL, so that the MySQL XA code knows
+to call the InnoDB prepare and commit, or rollback for the transaction. This
+MUST be called for every transaction for which the user may call commit or
+rollback. Calling this several times to register the same transaction is
+allowed, too.
+This function also registers the current SQL statement. */
+inline
+void
+innobase_register_trx_and_stmt(
+/*===========================*/
+	THD*	thd)	/* in: MySQL thd (connection) object */
+{
+	/* NOTE that actually innobase_register_stmt() registers also
+	the transaction in the AUTOCOMMIT=1 mode. */
+
+	innobase_register_stmt(thd);
 
         if (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) {
 
@@ -914,7 +934,7 @@
 
         if (trx->active_trans == 0) {
 
-                register_trans(thd);
+                innobase_register_trx_and_stmt(thd);
                 trx->active_trans = 1;
         }
 
@@ -1030,7 +1050,7 @@
 
         if (prebuilt->trx->active_trans == 0) {
 
-                register_trans(current_thd);
+                innobase_register_trx_and_stmt(current_thd);
 
                 prebuilt->trx->active_trans = 1;
         }
@@ -1421,7 +1441,7 @@
 
         if (trx->active_trans == 0) {
 
-                register_trans(current_thd);
+                innobase_register_trx_and_stmt(current_thd);
 
                 trx->active_trans = 1;
         }
@@ -5544,9 +5564,11 @@
 	/* Set the MySQL flag to mark that there is an active transaction */
         if (trx->active_trans == 0) {
 
-                register_trans(thd);
+                innobase_register_trx_and_stmt(thd);
                 trx->active_trans = 1;
-        }
+        } else {
+		innobase_register_stmt(thd);
+	}
 
 	return(0);
 }
@@ -5616,9 +5638,11 @@
 		transaction */
                 if (trx->active_trans == 0) {
 
-                        register_trans(thd);
+                        innobase_register_trx_and_stmt(thd);
                         trx->active_trans = 1;
-                }
+                } else if (trx->n_mysql_tables_in_use == 0) {
+			innobase_register_stmt(thd);
+		}
 
 		trx->n_mysql_tables_in_use++;
 		prebuilt->mysql_has_locked = TRUE;
@@ -5780,7 +5804,7 @@
 	/* Set the MySQL flag to mark that there is an active transaction */
         if (trx->active_trans == 0) {
 
-                register_trans(thd);
+                innobase_register_trx_and_stmt(thd);
                 trx->active_trans = 1;
         }
 
Thread
bk commit into 5.0 tree (heikki:1.1880) BUG#8650Heikki Tuuri5 Apr