List:Internals« Previous MessageNext Message »
From:dlenev Date:November 19 2005 1:12pm
Subject:bk commit into 5.0 tree (dlenev:1.1979)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of dlenev. When dlenev 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.1979 05/11/19 15:11:57 dlenev@stripped +5 -0
  Merge bk-internal.mysql.com:/home/bk/mysql-5.0
  into  mysql.com:/home/dlenev/src/mysql-5.0-bg13825

  sql/sql_parse.cc
    1.514 05/11/19 15:11:50 dlenev@stripped +0 -0
    Auto merged

  sql/sql_class.h
    1.274 05/11/19 15:11:49 dlenev@stripped +0 -0
    Auto merged

  sql/sql_class.cc
    1.220 05/11/19 15:11:49 dlenev@stripped +0 -0
    Auto merged

  sql/handler.cc
    1.203 05/11/19 15:11:49 dlenev@stripped +0 -0
    Auto merged

  sql/ha_innodb.cc
    1.278 05/11/19 15:11:49 dlenev@stripped +0 -0
    Auto merged

# 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:	dlenev
# Host:	brandersnatch.site
# Root:	/home/dlenev/src/mysql-5.0-bg13825/RESYNC

--- 1.202/sql/handler.cc	2005-11-03 15:24:47 +03:00
+++ 1.203/sql/handler.cc	2005-11-19 15:11:49 +03:00
@@ -1145,10 +1145,10 @@
 int ha_rollback_to_savepoint(THD *thd, SAVEPOINT *sv)
 {
   int error=0;
-  THD_TRANS *trans=&thd->transaction.all;
+  THD_TRANS *trans= (thd->in_sub_stmt ? &thd->transaction.stmt :
+                                        &thd->transaction.all);
   handlerton **ht=trans->ht, **end_ht;
   DBUG_ENTER("ha_rollback_to_savepoint");
-  DBUG_ASSERT(thd->transaction.stmt.ht[0] == 0);
 
   trans->nht=sv->nht;
   trans->no_2pc=0;
@@ -1176,7 +1176,7 @@
   for (; *ht ; ht++)
   {
     int err;
-    if ((err= (*(*ht)->rollback)(thd, 1)))
+    if ((err= (*(*ht)->rollback)(thd, !thd->in_sub_stmt)))
     { // cannot happen
       my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), err);
       error=1;
@@ -1196,10 +1196,10 @@
 int ha_savepoint(THD *thd, SAVEPOINT *sv)
 {
   int error=0;
-  THD_TRANS *trans=&thd->transaction.all;
+  THD_TRANS *trans= (thd->in_sub_stmt ? &thd->transaction.stmt :
+                                        &thd->transaction.all);
   handlerton **ht=trans->ht;
   DBUG_ENTER("ha_savepoint");
-  DBUG_ASSERT(thd->transaction.stmt.ht[0] == 0);
 #ifdef USING_TRANSACTIONS
   for (; *ht; ht++)
   {
@@ -1225,9 +1225,10 @@
 int ha_release_savepoint(THD *thd, SAVEPOINT *sv)
 {
   int error=0;
-  handlerton **ht=thd->transaction.all.ht, **end_ht;
+  THD_TRANS *trans= (thd->in_sub_stmt ? &thd->transaction.stmt :
+                                        &thd->transaction.all);
+  handlerton **ht=trans->ht, **end_ht;
   DBUG_ENTER("ha_release_savepoint");
-  DBUG_ASSERT(thd->transaction.stmt.ht[0] == 0);
 
   end_ht=ht+sv->nht;
   for (; ht < end_ht; ht++)

--- 1.219/sql/sql_class.cc	2005-11-16 12:13:06 +03:00
+++ 1.220/sql/sql_class.cc	2005-11-19 15:11:49 +03:00
@@ -1916,6 +1916,7 @@
   - Value for found_rows() is reset and restored
   - examined_row_count is added to the total
   - cuted_fields is added to the total
+  - new savepoint level is created and destroyed
 
   NOTES:
     Seed for random() is saved for the first! usage of RAND()
@@ -1939,6 +1940,7 @@
   backup->sent_row_count=   sent_row_count;
   backup->cuted_fields=     cuted_fields;
   backup->client_capabilities= client_capabilities;
+  backup->savepoints= transaction.savepoints;
 
   if (!lex->requires_prelocking() || is_update_query(lex->sql_command))
     options&= ~OPTION_BIN_LOG;
@@ -1951,6 +1953,7 @@
   examined_row_count= 0;
   sent_row_count= 0;
   cuted_fields= 0;
+  transaction.savepoints= 0;
 
 #ifndef EMBEDDED_LIBRARY
   /* Surpress OK packets in case if we will execute statements */
@@ -1961,6 +1964,21 @@
 
 void THD::restore_sub_statement_state(Sub_statement_state *backup)
 {
+  /*
+    To save resources we want to release savepoints which were created
+    during execution of function or trigger before leaving their savepoint
+    level. It is enough to release first savepoint set on this level since
+    all later savepoints will be released automatically.
+  */
+  if (transaction.savepoints)
+  {
+    SAVEPOINT *sv;
+    for (sv= transaction.savepoints; sv->prev; sv= sv->prev)
+    {}
+    /* ha_release_savepoint() never returns error. */
+    (void)ha_release_savepoint(this, sv);
+  }
+  transaction.savepoints= backup->savepoints;
   options=          backup->options;
   in_sub_stmt=      backup->in_sub_stmt;
   net.no_send_ok=   backup->no_send_ok;

--- 1.273/sql/sql_class.h	2005-11-14 16:00:59 +03:00
+++ 1.274/sql/sql_class.h	2005-11-19 15:11:49 +03:00
@@ -1091,6 +1091,7 @@
   uint in_sub_stmt;
   bool enable_slow_log, insert_id_used;
   my_bool no_send_ok;
+  SAVEPOINT *savepoints;
 };
 
 

--- 1.513/sql/sql_parse.cc	2005-11-17 03:15:01 +03:00
+++ 1.514/sql/sql_parse.cc	2005-11-19 15:11:50 +03:00
@@ -4033,8 +4033,8 @@
     break;
   }
   case SQLCOM_SAVEPOINT:
-    if (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) ||
-        !opt_using_transactions)
+    if (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN) ||
+          thd->in_sub_stmt) || !opt_using_transactions)
       send_ok(thd);
     else
     {

--- 1.277/sql/ha_innodb.cc	2005-11-17 17:02:37 +03:00
+++ 1.278/sql/ha_innodb.cc	2005-11-19 15:11:49 +03:00
@@ -2198,11 +2198,13 @@
 
 	DBUG_ENTER("innobase_savepoint");
 
-	if (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) {
-		/* In the autocommit state there is no sense to set a
-		savepoint: we return immediate success */
-	        DBUG_RETURN(0);
-	}
+        /*
+          In the autocommit mode there is no sense to set a savepoint
+          (unless we are in sub-statement), so SQL layer ensures that
+          this method is never called in such situation.
+        */
+        DBUG_ASSERT(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN) ||
+                    thd->in_sub_stmt);
 
 	trx = check_trx_exists(thd);
 
Thread
bk commit into 5.0 tree (dlenev:1.1979)dlenev19 Nov