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

 2665 Dmitry Lenev	2008-06-08
      WL#3726 "DDL locking for all metadata objects"
      
      After review fixes in progress.
      
      Some adjustments to the patch that removes thd->locked_tables and
      replaces thd->prelocked_mode with thd->locked_tables_mode.
modified:
  sql/sp_head.cc
  sql/sql_base.cc
  sql/sql_parse.cc

per-file comments:
  sql/sp_head.cc
    Fix conditions which were wrongly translated by previous patch.
  sql/sql_base.cc
    close_thread_tables():
      Add comment clarifying control flow in case of LTM_LOCK_TABLES
      mode and statements requiring prelocking.
      Be consistent with other places where we clear
      OPTION_TABLE_LOCK flag.
    lock_tables():
      Always set THD::lock to 0 after freeing memory to which it
      points.
  sql/sql_parse.cc
    Added back printing some debugging info removed by previous patch.
=== 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-06 19:19:04 +0000
+++ b/sql/sql_base.cc	2008-06-08 18:13:58 +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;
 }
 
@@ -5334,6 +5343,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:2665) WL#3726Dmitry Lenev8 Jun