List:Commits« Previous MessageNext Message »
From:dlenev Date:May 19 2007 6:58am
Subject:bk commit into 5.1 tree (dlenev:1.2529)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 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@stripped, 2007-05-19 10:58:01+04:00, dlenev@stripped +1 -0
  Merge bk-internal.mysql.com:/home/bk/mysql-5.1-runtime
  into  mockturtle.local:/home/dlenev/src/mysql-5.1-alter
  MERGE: 1.2526.1.1

  sql/sql_base.cc@stripped, 2007-05-19 10:57:54+04:00, dlenev@stripped +0 -0
    Auto merged
    MERGE: 1.401.1.1

# 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:	mockturtle.local
# Root:	/home/dlenev/src/mysql-5.1-alter/RESYNC

--- 1.402/sql/sql_base.cc	2007-05-19 10:58:12 +04:00
+++ 1.403/sql/sql_base.cc	2007-05-19 10:58:12 +04:00
@@ -99,7 +99,6 @@ static bool open_new_frm(THD *thd, TABLE
                          TABLE_LIST *table_desc, MEM_ROOT *mem_root);
 static void close_old_data_files(THD *thd, TABLE *table, bool morph_locks,
                                  bool send_refresh);
-static bool reopen_table(TABLE *table);
 static bool
 has_two_write_locked_tables_with_auto_increment(TABLE_LIST *tables);
 
@@ -681,7 +680,7 @@ TABLE_SHARE *get_cached_table_share(cons
 */
 
 
-static void close_handle_and_leave_table_as_lock(TABLE *table)
+void close_handle_and_leave_table_as_lock(TABLE *table)
 {
   TABLE_SHARE *share, *old_share= table->s;
   char *key_buff;
@@ -2712,7 +2711,7 @@ TABLE *find_locked_table(THD *thd, const
    1  error. The old table object is not changed.
 */
 
-static bool reopen_table(TABLE *table)
+bool reopen_table(TABLE *table)
 {
   TABLE tmp;
   bool error= 1;
@@ -2795,27 +2794,55 @@ static bool reopen_table(TABLE *table)
 }
 
 
-/*
-  Used with ALTER TABLE:
-  Close all instanses of table when LOCK TABLES is in used;
-  Close first all instances of table and then reopen them
+/**
+    @brief Close all instances of a table open by this thread and replace
+           them with exclusive name-locks.
+
+    @param thd        Thread context
+    @param db         Database name for the table to be closed
+    @param table_name Name of the table to be closed
+
+    @note This function assumes that if we are not under LOCK TABLES,
+          then there is only one table open and locked. This means that
+          the function probably has to be adjusted before it can be used
+          anywhere outside ALTER TABLE.
 */
 
-bool close_data_tables(THD *thd,const char *db, const char *table_name)
+void close_data_files_and_morph_locks(THD *thd, const char *db,
+                                      const char *table_name)
 {
   TABLE *table;
-  DBUG_ENTER("close_data_tables");
+  DBUG_ENTER("close_data_files_and_morph_locks");
+
+  safe_mutex_assert_owner(&LOCK_open);
+
+  if (thd->lock)
+  {
+    /*
+      If we are not under LOCK TABLES we should have only one table
+      open and locked so it makes sense to remove the lock at once.
+    */
+    mysql_unlock_tables(thd, thd->lock);
+    thd->lock= 0;
+  }
 
+  /*
+    Note that open table list may contain a name-lock placeholder
+    for target table name if we process ALTER TABLE ... RENAME.
+    So loop below makes sense even if we are not under LOCK TABLES.
+  */
   for (table=thd->open_tables; table ; table=table->next)
   {
     if (!strcmp(table->s->table_name.str, table_name) &&
 	!strcmp(table->s->db.str, db))
     {
-      mysql_lock_remove(thd, thd->locked_tables,table);
+      if (thd->locked_tables)
+        mysql_lock_remove(thd, thd->locked_tables, table);
+      table->open_placeholder= 1;
       close_handle_and_leave_table_as_lock(table);
     }
   }
-  DBUG_RETURN(0);                               // For the future
+  DBUG_VOID_RETURN;
 }
 
 
Thread
bk commit into 5.1 tree (dlenev:1.2529)dlenev19 May