List:Commits« Previous MessageNext Message »
From:Alfranio Correia Date:December 31 2009 2:27am
Subject:bzr commit into mysql-5.1-bugteam branch (alfranio.correia:3294)
Bug#47899
View as plain text  
#At file:///home/acorreia/workspace.sun/repository.mysql/bzrwork/bug-47899/mysql-5.1-bugteam/ based on revid:satya.bn@stripped

 3294 Alfranio Correia	2009-12-31
      BUG#47899 CREATE TABLE...SELECT binlogged wrongly if binlog_format=row
      
      Sketch of a patch.

    modified:
      sql/mysql_priv.h
      sql/sql_insert.cc
      sql/sql_parse.cc
      sql/sql_table.cc
=== modified file 'sql/mysql_priv.h'
--- a/sql/mysql_priv.h	2009-10-27 13:20:34 +0000
+++ b/sql/mysql_priv.h	2009-12-31 02:27:44 +0000
@@ -1225,13 +1225,13 @@ int prepare_create_field(Create_field *s
 bool mysql_create_table(THD *thd,const char *db, const char *table_name,
                         HA_CREATE_INFO *create_info,
                         Alter_info *alter_info,
-                        bool tmp_table, uint select_field_count);
+                        bool tmp_table, uint select_field_count,
+                        bool unlock= TRUE);
 bool mysql_create_table_no_lock(THD *thd, const char *db,
                                 const char *table_name,
                                 HA_CREATE_INFO *create_info,
                                 Alter_info *alter_info,
                                 bool tmp_table, uint select_field_count);
-
 bool mysql_alter_table(THD *thd, char *new_db, char *new_name,
                        HA_CREATE_INFO *create_info,
                        TABLE_LIST *table_list,

=== modified file 'sql/sql_insert.cc'
--- a/sql/sql_insert.cc	2009-12-17 06:52:43 +0000
+++ b/sql/sql_insert.cc	2009-12-31 02:27:44 +0000
@@ -3741,6 +3741,7 @@ select_create::binlog_show_create_table(
   tmp_table_list.table = *tables;
   query.length(0);      // Have to zero it since constructor doesn't
 
+  query.append("/*KEEP LOCKS*/ ");
   result= store_create_info(thd, &tmp_table_list, &query, create_info,
                             /* show_database */ TRUE);
   DBUG_ASSERT(result == 0); /* store_create_info() always return 0 */

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2009-12-18 18:44:24 +0000
+++ b/sql/sql_parse.cc	2009-12-31 02:27:44 +0000
@@ -1993,6 +1993,7 @@ bool sp_process_definer(THD *thd)
 int
 mysql_execute_command(THD *thd)
 {
+  bool unlock= TRUE;
   int res= FALSE;
   bool need_start_waiting= FALSE; // have protection against global read lock
   int  up_result= 0;
@@ -2506,7 +2507,8 @@ mysql_execute_command(THD *thd)
     /* If CREATE TABLE of non-temporary table, do implicit commit */
     if (!(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE))
     {
-      if (end_active_trans(thd))
+      unlock= (strstr(thd->query(), "/*KEEP LOCKS*/ ") == NULL);
+      if (unlock && end_active_trans(thd))
       {
 	res= -1;
 	break;
@@ -2729,9 +2731,14 @@ mysql_execute_command(THD *thd)
                                      &create_info);
       else
       {
+#ifndef DBUG_OFF
+        if (!unlock)
+          DBUG_PRINT("debug", ("The table %s will be kept locked and open.",
+                               create_table->table_name));
+#endif
         res= mysql_create_table(thd, create_table->db,
                                 create_table->table_name, &create_info,
-                                &alter_info, 0, 0);
+                                &alter_info, 0, 0, unlock);
       }
       if (!res)
 	my_ok(thd);

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2009-12-18 18:44:24 +0000
+++ b/sql/sql_table.cc	2009-12-31 02:27:44 +0000
@@ -3971,7 +3971,8 @@ bool mysql_create_table(THD *thd, const 
                         HA_CREATE_INFO *create_info,
                         Alter_info *alter_info,
                         bool internal_tmp_table,
-                        uint select_field_count)
+                        uint select_field_count,
+                        bool unlock)
 {
   TABLE *name_lock= 0;
   bool result;
@@ -4027,7 +4028,7 @@ bool mysql_create_table(THD *thd, const 
                                      select_field_count);
 
 unlock:
-  if (name_lock)
+  if (name_lock && unlock)
   {
     pthread_mutex_lock(&LOCK_open);
     unlink_open_table(thd, name_lock, FALSE);


Attachment: [text/bzr-bundle]
Thread
bzr commit into mysql-5.1-bugteam branch (alfranio.correia:3294)Bug#47899Alfranio Correia31 Dec