List:Commits« Previous MessageNext Message »
From:Dmitry Lenev Date:June 11 2008 2:51pm
Subject:bzr commit into mysql-6.0 branch (dlenev:2666) WL#3726
View as plain text  
#At file:///home/dlenev/src/bzr/mysql-6.0-3726-w2/

 2666 Dmitry Lenev	2008-06-11 [merge]
      Merge of after review changes for WL#3726 with current
      mysql-6.0-3726 tree.
modified:
  sql/sp_head.cc
  sql/sql_base.cc
  sql/sql_parse.cc

=== modified file 'sql/sp_head.cc'
--- a/sql/sp_head.cc	2008-06-06 19:19:04 +0000
+++ b/sql/sp_head.cc	2008-06-08 18:13:58 +0000
@@ -1233,7 +1233,7 @@ sp_head::execute(THD *thd)
       Will write this SP statement into binlog separately
       (TODO: consider changing the condition to "not inside event union")
     */
-    if (thd->locked_tables_mode == LTM_NONE)
+    if (thd->locked_tables_mode <= LTM_LOCK_TABLES)
       thd->user_var_events_alloc= thd->mem_root;
 
     err_status= i->execute(thd, &ip);
@@ -1245,7 +1245,7 @@ sp_head::execute(THD *thd)
       If we've set thd->user_var_events_alloc to mem_root of this SP
       statement, clean all the events allocated in it.
     */
-    if (thd->locked_tables_mode == LTM_NONE)
+    if (thd->locked_tables_mode <= LTM_LOCK_TABLES)
     {
       reset_dynamic(&thd->user_var_events);
       thd->user_var_events_alloc= NULL;//DEBUG
@@ -2687,7 +2687,7 @@ sp_lex_keeper::reset_lex_and_exec_core(T
   thd->query_id= next_query_id();
   pthread_mutex_unlock(&LOCK_thread_count);
 
-  if (thd->locked_tables_mode == LTM_NONE)
+  if (thd->locked_tables_mode <= LTM_LOCK_TABLES)
   {
     /*
       This statement will enter/leave prelocked mode on its own.

=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc	2008-06-09 10:01:19 +0000
+++ b/sql/sql_base.cc	2008-06-11 12:50:51 +0000
@@ -1328,6 +1328,7 @@ void close_thread_tables(THD *thd,
                          bool skip_mdl)
 {
   TABLE *table;
+  bool clear_table_lock_option= FALSE;
   DBUG_ENTER("close_thread_tables");
 
 #ifdef EXTRA_DEBUG
@@ -1399,6 +1400,11 @@ void close_thread_tables(THD *thd,
     /*
       We are under simple LOCK TABLES or we're inside a sub-statement
       of a prelocked statement, so should not do anything else.
+
+      Note that even if we are in LTM_LOCK_TABLES mode and statement
+      requires prelocking (e.g. when we are closing tables after
+      failing ot "open" all tables required for statement execution)
+      we will exit this function a few lines below.
     */
     if (! thd->lex->requires_prelocking())
       DBUG_VOID_RETURN;
@@ -1415,7 +1421,7 @@ void close_thread_tables(THD *thd,
       DBUG_VOID_RETURN;
 
     thd->locked_tables_mode= LTM_NONE;
-    thd->options&= ~OPTION_TABLE_LOCK;
+    clear_table_lock_option= TRUE;
 
     /*
       Note that we are leaving prelocked mode so we don't need
@@ -1455,6 +1461,9 @@ void close_thread_tables(THD *thd,
     mdl_remove_all_locks(&thd->mdl_context);
   }
 
+  if (clear_table_lock_option)
+    thd->options&= ~OPTION_TABLE_LOCK;
+
   DBUG_VOID_RETURN;
 }
 
@@ -5324,6 +5333,7 @@ int lock_tables(THD *thd, TABLE_LIST *ta
               need to care about THD::locked_tables_root here.
             */
             mysql_unlock_tables(thd, thd->lock);
+            thd->lock= 0;
             thd->options&= ~(OPTION_TABLE_LOCK);
             DBUG_RETURN(-1);
           }

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2008-06-06 19:19:04 +0000
+++ b/sql/sql_parse.cc	2008-06-08 18:13:58 +0000
@@ -3293,8 +3293,10 @@ end_with_restore_list:
       - no non-transactional locks exist (!thd->locked_tables_mode).
     */
     DBUG_PRINT("lock_info", ("lex->lock_transactional: %d  "
+                             "thd->locked_tables_mode: %d  "
                              "thd->lock: %p",
                              lex->lock_transactional,
+                             thd->locked_tables_mode,
                              thd->lock));
     if (lex->lock_transactional && !thd->locked_tables_mode)
     {

Thread
bzr commit into mysql-6.0 branch (dlenev:2666) WL#3726Dmitry Lenev11 Jun