List:Commits« Previous MessageNext Message »
From:Andrei Elkin Date:November 30 2006 10:53pm
Subject:bk commit into 5.1 tree (aelkin:1.2374) BUG#24738
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of elkin. When elkin 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@stripped, 2006-12-01 00:52:50+02:00, aelkin@stripped +1 -0
  Bug #24738 create .. select is not isolated properly
  
  The query constists of two separate parts: create new and insert selected.
  The new table can be modified of dropped by an external connection before
  the second inserting part acquires the lock for new table.
  There are several at least undesired things:
  
   1. The user can end up to see
       ERROR 1146 (42S02): Table 'new_table' does not exists.
   2. new table can be DROPed by external connection, and to footprint the fact in binlog,
      whereas CREATE..SELECT would end with the error and did not leave anything
      in binlog. Eventually slave will stop because DROP won't find the new table on slave;
  
   many others.
    
  Fixed with lock_and_wait_for_table_name before mysql_create_table and 
  unlock_table_name after mysql_lock_tables at  create_table_from_items.
    

  sql/sql_insert.cc@stripped, 2006-12-01 00:52:45+02:00, aelkin@stripped +15 -0
    lock_and_wait_for_table_name before mysql_create_table and 
    unlock_table_name after mysql_lock_tables.

# 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:	aelkin
# Host:	dsl-hkibras-fe30f900-107.dhcp.inet.fi
# Root:	/home/elkin/MySQL/TEAM/BARE/mysql-5.1-new-rpl

--- 1.234/sql/sql_insert.cc	2006-12-01 00:53:00 +02:00
+++ 1.235/sql/sql_insert.cc	2006-12-01 00:53:00 +02:00
@@ -2886,6 +2886,10 @@ static TABLE *create_table_from_items(TH
     by the statement we create potential window for deadlock.
     TODO: create and open should be done atomic !
   */
+
+  if (lock_and_wait_for_table_name(thd, create_table))
+    DBUG_RETURN(0);
+
   {
     tmp_disable_binlog(thd);
     if (!mysql_create_table(thd, create_table->db, create_table->table_name,
@@ -2914,9 +2918,16 @@ static TABLE *create_table_from_items(TH
                        table_case_name(create_info, create_table->table_name),
                        0);
     }
+
     reenable_binlog(thd);
+    
     if (!table)                                   // open failed
+    {
+      VOID(pthread_mutex_lock(&LOCK_open));
+      unlock_table_name(thd, create_table);
+      VOID(pthread_mutex_unlock(&LOCK_open));
       DBUG_RETURN(0);
+    }
   }
 
   /*
@@ -2932,11 +2943,15 @@ static TABLE *create_table_from_items(TH
   {
     VOID(pthread_mutex_lock(&LOCK_open));
     hash_delete(&open_cache,(byte*) table);
+    unlock_table_name(thd, create_table);
     VOID(pthread_mutex_unlock(&LOCK_open));
     quick_rm_table(create_info->db_type, create_table->db,
 		   table_case_name(create_info, create_table->table_name), 0);
     DBUG_RETURN(0);
   }
+  VOID(pthread_mutex_lock(&LOCK_open));
+  unlock_table_name(thd, create_table);
+  VOID(pthread_mutex_unlock(&LOCK_open));
   table->file->extra(HA_EXTRA_WRITE_CACHE);
   DBUG_RETURN(table);
 }
Thread
bk commit into 5.1 tree (aelkin:1.2374) BUG#24738Andrei Elkin30 Nov