List:Commits« Previous MessageNext Message »
From:ingo Date:June 26 2006 7:19pm
Subject:bk commit into 5.0 tree (ingo:1.2197)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of mydev. When mydev 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.2197 06/06/26 19:19:12 ingo@stripped +3 -0
  Merge mysql.com:/home/mydev/mysql-5.0--main
  into  mysql.com:/home/mydev/mysql-5.0-bug16986-main

  sql/sql_parse.cc
    1.554 06/06/26 19:19:04 ingo@stripped +0 -0
    Auto merged

  sql/sql_base.cc
    1.343 06/06/26 19:19:04 ingo@stripped +0 -0
    Auto merged

  sql/mysql_priv.h
    1.395 06/06/26 19:19:04 ingo@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:	ingo
# Host:	chilla.local
# Root:	/home/mydev/mysql-5.0-bug16986-main/RESYNC

--- 1.394/sql/mysql_priv.h	2006-06-21 11:12:40 +02:00
+++ 1.395/sql/mysql_priv.h	2006-06-26 19:19:04 +02:00
@@ -1344,6 +1344,7 @@ void start_waiting_global_read_lock(THD 
 bool make_global_read_lock_block_commit(THD *thd);
 bool set_protect_against_global_read_lock(void);
 void unset_protect_against_global_read_lock(void);
+void broadcast_refresh(void);
 
 /* Lock based on name */
 int lock_and_wait_for_table_name(THD *thd, TABLE_LIST *table_list);

--- 1.342/sql/sql_base.cc	2006-06-21 11:25:35 +02:00
+++ 1.343/sql/sql_base.cc	2006-06-26 19:19:04 +02:00
@@ -530,7 +530,7 @@ void close_thread_tables(THD *thd, bool 
   if (found_old_table)
   {
     /* Tell threads waiting for refresh that something has happened */
-    VOID(pthread_cond_broadcast(&COND_refresh));
+    broadcast_refresh();
   }
   if (!lock_in_use)
     VOID(pthread_mutex_unlock(&LOCK_open));
@@ -1035,7 +1035,7 @@ TABLE *unlink_open_table(THD *thd, TABLE
   }
   *prev=0;
   // Notify any 'refresh' threads
-  pthread_cond_broadcast(&COND_refresh);
+  broadcast_refresh();
   return start;
 }
 
@@ -1577,7 +1577,7 @@ bool reopen_table(TABLE *table,bool lock
   if (table->triggers)
     table->triggers->set_table(table);
 
-  VOID(pthread_cond_broadcast(&COND_refresh));
+  broadcast_refresh();
   error=0;
 
  end:
@@ -1678,7 +1678,7 @@ bool reopen_tables(THD *thd,bool get_loc
   {
     my_afree((gptr) tables);
   }
-  VOID(pthread_cond_broadcast(&COND_refresh)); // Signal to refresh
+  broadcast_refresh();
   *prev=0;
   DBUG_RETURN(error);
 }
@@ -1715,7 +1715,7 @@ void close_old_data_files(THD *thd, TABL
     }
   }
   if (found)
-    VOID(pthread_cond_broadcast(&COND_refresh)); // Signal to refresh
+    broadcast_refresh();
   DBUG_VOID_RETURN;
 }
 
@@ -1807,7 +1807,7 @@ bool drop_locked_tables(THD *thd,const c
   }
   *prev=0;
   if (found)
-    VOID(pthread_cond_broadcast(&COND_refresh)); // Signal to refresh
+    broadcast_refresh();
   if (thd->locked_tables && thd->locked_tables->table_count == 0)
   {
     my_free((gptr) thd->locked_tables,MYF(0));
@@ -5249,7 +5249,7 @@ bool remove_table_from_cache(THD *thd, c
         Signal any thread waiting for tables to be freed to
         reopen their tables
       */
-      (void) pthread_cond_broadcast(&COND_refresh);
+      broadcast_refresh();
       DBUG_PRINT("info", ("Waiting for refresh signal"));
       if (!(flags & RTFC_CHECK_KILLED_FLAG) || !thd->killed)
       {

--- 1.553/sql/sql_parse.cc	2006-06-23 14:09:31 +02:00
+++ 1.554/sql/sql_parse.cc	2006-06-26 19:19:04 +02:00
@@ -2337,17 +2337,37 @@ static void reset_one_shot_variables(THD
 }
 
 
-/****************************************************************************
-** mysql_execute_command
-** Execute command saved in thd and current_lex->sql_command
-****************************************************************************/
+/*
+  Execute command saved in thd and current_lex->sql_command
+
+  SYNOPSIS
+    mysql_execute_command()
+      thd                       Thread handle
+
+  IMPLEMENTATION
+
+    Before every operation that can request a write lock for a table
+    wait if a global read lock exists. However do not wait if this
+    thread has locked tables already. No new locks can be requested
+    until the other locks are released. The thread that requests the
+    global read lock waits for write locked tables to become unlocked.
+
+    Note that wait_if_global_read_lock() sets a protection against a new
+    global read lock when it succeeds. This needs to be released by
+    start_waiting_global_read_lock() after the operation.
+
+  RETURN
+    FALSE       OK
+    TRUE        Error
+*/
 
 bool
 mysql_execute_command(THD *thd)
 {
-  bool	res= FALSE;
-  int result= 0;
-  LEX	*lex= thd->lex;
+  bool res= FALSE;
+  bool need_start_waiting= FALSE; // have protection against global read lock
+  int  result= 0;
+  LEX  *lex= thd->lex;
   /* first SELECT_LEX (have special meaning for many of non-SELECTcommands) */
   SELECT_LEX *select_lex= &lex->select_lex;
   /* first table of first SELECT_LEX */
@@ -2832,7 +2852,8 @@ mysql_execute_command(THD *thd)
       TABLE in the same way. That way we avoid that a new table is
       created during a gobal read lock.
     */
-    if (wait_if_global_read_lock(thd, 0, 1))
+    if (!thd->locked_tables &&
+        !(need_start_waiting= !wait_if_global_read_lock(thd, 0, 1)))
     {
       res= 1;
       goto end_with_restore_list;
@@ -2857,7 +2878,7 @@ mysql_execute_command(THD *thd)
           {
             update_non_unique_table_error(create_table, "CREATE", duplicate);
             res= 1;
-            goto end_with_restart_wait;
+            goto end_with_restore_list;
           }
         }
         /* If we create merge table, we have to test tables in merge, too */
@@ -2873,7 +2894,7 @@ mysql_execute_command(THD *thd)
             {
               update_non_unique_table_error(tab, "CREATE", duplicate);
               res= 1;
-              goto end_with_restart_wait;
+              goto end_with_restore_list;
             }
           }
         }
@@ -2915,13 +2936,6 @@ mysql_execute_command(THD *thd)
 	send_ok(thd);
     }
 
-end_with_restart_wait:
-    /*
-      Release the protection against the global read lock and wake
-      everyone, who might want to set a global read lock.
-    */
-    start_waiting_global_read_lock(thd);
-
     /* put tables back for PS rexecuting */
 end_with_restore_list:
     lex->link_first_table_back(create_table, link_to_local);
@@ -3039,6 +3053,13 @@ end_with_restore_list:
 	goto error;
       else
       {
+        if (!thd->locked_tables &&
+            !(need_start_waiting= !wait_if_global_read_lock(thd, 0, 1)))
+        {
+          res= 1;
+          break;
+        }
+
         thd->enable_slow_log= opt_log_slow_admin_statements;
 	res= mysql_alter_table(thd, select_lex->db, lex->name,
 			       &lex->create_info,
@@ -3296,6 +3317,14 @@ end_with_restore_list:
       break;
     /* Skip first table, which is the table we are inserting in */
     select_lex->context.table_list= first_table->next_local;
+
+    if (!thd->locked_tables &&
+        !(need_start_waiting= !wait_if_global_read_lock(thd, 0, 1)))
+    {
+      res= 1;
+      break;
+    }
+
     res= mysql_insert(thd, all_tables, lex->field_list, lex->many_values,
 		      lex->update_list, lex->value_list,
                       lex->duplicates, lex->ignore);
@@ -3319,6 +3348,14 @@ end_with_restore_list:
     select_lex->options|= SELECT_NO_UNLOCK;
 
     unit->set_limit(select_lex);
+
+    if (! thd->locked_tables &&
+        ! (need_start_waiting= ! wait_if_global_read_lock(thd, 0, 1)))
+    {
+      res= 1;
+      break;
+    }
+
     if (!(res= open_and_lock_tables(thd, all_tables)))
     {
       /* Skip first table, which is the table we are inserting in */
@@ -3386,6 +3423,14 @@ end_with_restore_list:
       break;
     DBUG_ASSERT(select_lex->offset_limit == 0);
     unit->set_limit(select_lex);
+
+    if (!thd->locked_tables &&
+        !(need_start_waiting= !wait_if_global_read_lock(thd, 0, 1)))
+    {
+      res= 1;
+      break;
+    }
+
     res = mysql_delete(thd, all_tables, select_lex->where,
                        &select_lex->order_list,
                        unit->select_limit_cnt, select_lex->options,
@@ -3399,6 +3444,13 @@ end_with_restore_list:
       (TABLE_LIST *)thd->lex->auxilliary_table_list.first;
     multi_delete *result;
 
+    if (!thd->locked_tables &&
+        !(need_start_waiting= !wait_if_global_read_lock(thd, 0, 1)))
+    {
+      res= 1;
+      break;
+    }
+
     if ((res= multi_delete_precheck(thd, all_tables)))
       break;
 
@@ -4965,10 +5017,22 @@ end_with_restore_list:
   if (lex->sql_command != SQLCOM_CALL && lex->sql_command != SQLCOM_EXECUTE
&&
       uc_update_queries[lex->sql_command]<2)
     thd->row_count_func= -1;
-  DBUG_RETURN(res || thd->net.report_error);
+
+  goto end;
 
 error:
-  DBUG_RETURN(1);
+  res= TRUE;
+
+end:
+  if (need_start_waiting)
+  {
+    /*
+      Release the protection against the global read lock and wake
+      everyone, who might want to set a global read lock.
+    */
+    start_waiting_global_read_lock(thd);
+  }
+  DBUG_RETURN(res || thd->net.report_error);
 }
 
 
Thread
bk commit into 5.0 tree (ingo:1.2197)ingo26 Jun