List:Commits« Previous MessageNext Message »
From:Petr Chardin Date:September 7 2006 9:30am
Subject:bk commit into 5.1 tree (petr:1.2285) BUG#21785
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of cps. When cps 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-09-07 11:30:47+04:00, petr@stripped +6 -0
  Fix for Bug #17544 "Cannot do atomic log rotate" and
  Bug #21785 "Server crashes after rename of the log table"
  
  From now on, one should use RENAME to perform a log table
  rotation (this should also be reflected in the manual).
  
  Here is a sample:
  
  use mysql;
  CREATE TABLE IF NOT EXISTS general_log2 LIKE general_log;
  RENAME TABLE general_log TO general_log_backup, general_log2 TO general_log;
  
  The rules for Rename of the log tables are following:
        IF   1. Log tables are enabled
        AND  2. Rename operates on the log table and nothing is being
                renamed to the log table.
        DO   3. Throw an error message.
        ELSE 4. Perform rename.
  
  The very RENAME query will go the the old (backup) table. This is
  consistent with the behavoiur we have with binlog ROTATE LOGS
  statement.

  mysql-test/r/log_tables.result@stripped, 2006-09-07 11:30:44+04:00, petr@stripped +33 -0
    update result file.
    Note: there is a warning from CREATE TABLE LIKE statement.
          It should go away with the fix for bug
          Bug #21966 "Strange warnings on repair of the log tables"
          I plan to commit the fix this week (based on this CS)

  mysql-test/t/log_tables.test@stripped, 2006-09-07 11:30:44+04:00, petr@stripped +44 -0
    Add tests for bugs

  sql/log.cc@stripped, 2006-09-07 11:30:45+04:00, petr@stripped +125 -80
    Changes to the file:
      1) Add checks for table schema. It's more important now,
         as we allow rename of the log tables. Since we should
         check for schema when writing to a log table.
         E.g. if one created a table with one-only comlumn and
         renamed it to general_log, the server should cope with
         it.
      2) refactor LOGGER::flush(), so that we can now use the same
         machinery as we use in FLUSH LOGS in other statements:
         whenever we have to perform  a serious operation on the log
         tables, we have to
         (a) wait for concurrent operations on the log tables (such 
         as selects) to stop (b) close logs (c) lock logger, so that
         nobody attempts to write to closed logs. Then perform an
         exclusive operation, d) reenable logs and e) unlock logger.

  sql/log.h@stripped, 2006-09-07 11:30:45+04:00, petr@stripped +2 -2
    add a new call close_n_lock_tables(). Now we use it instead of
    LOGGER::flush() in FLUSH LOGS implementation.

  sql/share/errmsg.txt@stripped, 2006-09-07 11:30:45+04:00, petr@stripped +2 -0
    Add a new error message for rename of the log tables

  sql/sql_rename.cc@stripped, 2006-09-07 11:30:45+04:00, petr@stripped +92 -1
    1) add a new function, which chechs if a given table is
       a log table
    2) Traverse the list of tables in mysql_rename_tables
       to make sure that log tables are processed correctly
       (that is, according to the rules specified in the
        main CS comment)

# 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:	petr
# Host:	owlet.local
# Root:	/home/cps/mysql/devel/5.1-rename-bug

--- 1.223/sql/log.cc	2006-09-07 11:30:58 +04:00
+++ 1.224/sql/log.cc	2006-09-07 11:30:58 +04:00
@@ -314,9 +314,6 @@ bool Log_to_csv_event_handler::
     filled by the Logger (=> no need to load default ones).
   */
 
-  /* log table entries are not replicated at the moment */
-  tmp_disable_binlog(current_thd);
-
   /* Set current time. Required for CURRENT_TIMESTAMP to work */
   general_log_thd->start_time= event_time;
 
@@ -325,21 +322,36 @@ bool Log_to_csv_event_handler::
     default value (which is CURRENT_TIMESTAMP).
   */
 
-  table->field[1]->store(user_host, user_host_len, client_cs);
+  /* check that all columns exist */
+  if (!table->field[1] || !table->field[2] || !table->field[3] ||
+      !table->field[4] || !table->field[5])
+    goto err;
+
+  /* do a write */
+  if (table->field[1]->store(user_host, user_host_len, client_cs) ||
+      table->field[2]->store((longlong) thread_id, TRUE) ||
+      table->field[3]->store((longlong) server_id, TRUE) ||
+      table->field[4]->store(command_type, command_type_len, client_cs) ||
+      table->field[5]->store(sql_text, sql_text_len, client_cs))
+    goto err;
+
+  /* mark tables as not null */
   table->field[1]->set_notnull();
-  table->field[2]->store((longlong) thread_id, TRUE);
   table->field[2]->set_notnull();
-  table->field[3]->store((longlong) server_id, TRUE);
   table->field[3]->set_notnull();
-  table->field[4]->store(command_type, command_type_len, client_cs);
   table->field[4]->set_notnull();
-  table->field[5]->store(sql_text, sql_text_len, client_cs);
   table->field[5]->set_notnull();
+
+  /* log table entries are not replicated at the moment */
+  tmp_disable_binlog(current_thd);
+
   table->file->ha_write_row(table->record[0]);
 
   reenable_binlog(current_thd);
 
   return FALSE;
+err:
+  return TRUE;
 }
 
 
@@ -388,9 +400,6 @@ bool Log_to_csv_event_handler::
   if (unlikely(!logger.is_log_tables_initialized))
     return FALSE;
 
-  /* log table entries are not replicated at the moment */
-  tmp_disable_binlog(current_thd);
-
   /*
      Set start time for CURRENT_TIMESTAMP to the start of the query.
      This will be default value for the field[0]
@@ -403,19 +412,30 @@ bool Log_to_csv_event_handler::
     default value.
   */
 
+  if (!table->field[1] || !table->field[2] || !table->field[3] ||
+      !table->field[4] || !table->field[5] || !table->field[6] ||
+      !table->field[7] || !table->field[8] || !table->field[9] ||
+      !table->field[10])
+    goto err;
+
   /* store the value */
-  table->field[1]->store(user_host, user_host_len, client_cs);
+  if (table->field[1]->store(user_host, user_host_len, client_cs))
+    goto err;
 
   if (query_start_arg)
   {
     /* fill in query_time field */
-    table->field[2]->store(query_time, TRUE);
+    if (table->field[2]->store(query_time, TRUE))
+      goto err;
     /* lock_time */
-    table->field[3]->store(lock_time, TRUE);
+    if (table->field[3]->store(lock_time, TRUE))
+      goto err;
     /* rows_sent */
-    table->field[4]->store((longlong) thd->sent_row_count, TRUE);
+    if (table->field[4]->store((longlong) thd->sent_row_count, TRUE))
+      goto err;
     /* rows_examined */
-    table->field[5]->store((longlong) thd->examined_row_count, TRUE);
+    if (table->field[5]->store((longlong) thd->examined_row_count, TRUE))
+      goto err;
   }
   else
   {
@@ -428,14 +448,18 @@ bool Log_to_csv_event_handler::
   /* fill database field */
   if (thd->db)
   {
-    table->field[6]->store(thd->db, thd->db_length, client_cs);
+    if (table->field[6]->store(thd->db, thd->db_length, client_cs))
+      goto err;
     table->field[6]->set_notnull();
   }
 
   if (thd->stmt_depends_on_first_successful_insert_id_in_prev_stmt)
   {
-    table->field[7]->store((longlong)
-                           thd->first_successful_insert_id_in_prev_stmt_for_binlog,
TRUE);
+    if (table->
+        field[7]->store((longlong)
+                        thd->first_successful_insert_id_in_prev_stmt_for_binlog,
+                        TRUE))
+      goto err;
     table->field[7]->set_notnull();
   }
 
@@ -447,16 +471,23 @@ bool Log_to_csv_event_handler::
   */
   if (thd->auto_inc_intervals_in_cur_stmt_for_binlog.nb_elements() > 0)
   {
-    table->field[8]->store((longlong)
-                           thd->auto_inc_intervals_in_cur_stmt_for_binlog.minimum(),
TRUE);
+    if (table->
+        field[8]->store((longlong)
+          thd->auto_inc_intervals_in_cur_stmt_for_binlog.minimum(), TRUE))
+      goto err;
     table->field[8]->set_notnull();
   }
 
-  table->field[9]->store((longlong) server_id, TRUE);
+  if (table->field[9]->store((longlong) server_id, TRUE))
+    goto err;
   table->field[9]->set_notnull();
 
   /* sql_text */
-  table->field[10]->store(sql_text,sql_text_len, client_cs);
+  if (table->field[10]->store(sql_text,sql_text_len, client_cs))
+    goto err;
+
+  /* log table entries are not replicated at the moment */
+  tmp_disable_binlog(current_thd);
 
   /* write the row */
   table->file->ha_write_row(table->record[0]);
@@ -464,6 +495,8 @@ bool Log_to_csv_event_handler::
   reenable_binlog(current_thd);
 
   DBUG_RETURN(0);
+err:
+  DBUG_RETURN(1);
 }
 
 bool Log_to_csv_event_handler::
@@ -652,61 +685,45 @@ bool LOGGER::reopen_log_table(uint log_t
   return table_log_handler->reopen_log_table(log_table_type);
 }
 
+void LOGGER::close_n_lock_tables()
+{
+  table_log_handler->close_n_lock_tables();
+}
 
 bool LOGGER::flush_logs(THD *thd)
 {
-  TABLE_LIST close_slow_log, close_general_log;
-
-  /* reopen log tables */
-  bzero((char*) &close_slow_log, sizeof(TABLE_LIST));
-  close_slow_log.alias= close_slow_log.table_name=(char*) "slow_log";
-  close_slow_log.table_name_length= 8;
-  close_slow_log.db= (char*) "mysql";
-  close_slow_log.db_length= 5;
-
-  bzero((char*) &close_general_log, sizeof(TABLE_LIST));
-  close_general_log.alias= close_general_log.table_name=(char*) "general_log";
-  close_general_log.table_name_length= 11;
-  close_general_log.db= (char*) "mysql";
-  close_general_log.db_length= 5;
-
-  /* lock tables, in the case they are enabled */
-  if (logger.is_log_tables_initialized)
-  {
-    /*
-      This will lock and wait for all but the logger thread to release the
-      tables. Then we could reopen log tables. Then release the name locks.
-
-      NOTE: in fact, the first parameter used in lock_and_wait_for_table_name()
-      and table_log_handler->flush() could be any non-NULL THD, as the
-      underlying code makes certain assumptions about this.
-      Here we use one of the logger handler THD's. Simply because it
-      seems appropriate.
-    */
-    if (opt_slow_log)
-      lock_and_wait_for_table_name(table_log_handler->general_log_thd,
-				   &close_slow_log);
-    if (opt_log)
-      lock_and_wait_for_table_name(table_log_handler->general_log_thd,
-				   &close_general_log);
-  }
-
+  int rc= 0;
   /*
-    Deny others from logging to general and slow log,
-    while reopening tables.
+    Close log tables, in the case they are enabled and lock logger.
+    We always need to do this at the same time, as once the log tables
+    are closed, we cannot allow other threads to write anything to them.
+
+    In the case we don't use log tables, we still need to lock logger,
+    as we are going to flush log files, and again no concurrent writes
+    are allowed.
   */
-  logger.lock();
+  if (logger.is_log_tables_initialized)
+    table_log_handler->close_n_lock_tables(); // the locking happens here
+  else
+    logger.lock();
 
   /* reopen log files */
   file_log_handler->flush();
 
-  /* flush tables, in the case they are enabled */
+  /* reopen tables in the case they were enabled */
   if (logger.is_log_tables_initialized)
-    table_log_handler->flush(table_log_handler->general_log_thd,
-                             &close_slow_log, &close_general_log);
+  {
+    /*
+      we use | and not || here, to ensure that both reopen_log_table
+      are called, even if the first one fails
+    */
+    if ((opt_slow_log && table_log_handler->reopen_log_table(QUERY_LOG_SLOW))
|
+        (opt_log && table_log_handler->reopen_log_table(QUERY_LOG_GENERAL)))
+      rc= TRUE;
+  }
   /* end of log flush */
   logger.unlock();
-  return FALSE;
+  return rc;
 }
 
 
@@ -1014,31 +1031,59 @@ void LOGGER::deactivate_log_handler(THD 
 }
 
 
-bool Log_to_csv_event_handler::flush(THD *thd, TABLE_LIST *close_slow_log,
-                                     TABLE_LIST *close_general_log)
+void Log_to_csv_event_handler::close_n_lock_tables()
 {
+  TABLE_LIST close_slow_log, close_general_log;
+
+  /* fill lists, we will need to perform operations on tables */
+  bzero((char*) &close_slow_log, sizeof(TABLE_LIST));
+  close_slow_log.alias= close_slow_log.table_name=(char*) "slow_log";
+  close_slow_log.table_name_length= 8;
+  close_slow_log.db= (char*) "mysql";
+  close_slow_log.db_length= 5;
+
+  bzero((char*) &close_general_log, sizeof(TABLE_LIST));
+  close_general_log.alias= close_general_log.table_name=(char*) "general_log";
+  close_general_log.table_name_length= 11;
+  close_general_log.db= (char*) "mysql";
+  close_general_log.db_length= 5;
+
+  /*
+    This will lock and wait for all but the logger thread to release the
+    tables. Then we could close log tables and lock logger. Then release
+    the name locks.
+
+    NOTE: in fact, the first parameter used in lock_and_wait_for_table_name()
+    and table_log_handler->flush() could be any non-NULL THD, as the
+    underlying code makes certain assumptions about this.
+    Here we use one of the logger handler THD's. Simply because it
+    seems appropriate.
+  */
+  if (opt_slow_log)
+    lock_and_wait_for_table_name(general_log_thd, &close_slow_log);
+  if (opt_log)
+    lock_and_wait_for_table_name(general_log_thd, &close_general_log);
+
+  /*
+    Now we lock logger, as nobody should be able to use logging routines while
+    log tables are closed
+  */
+  logger.lock();
+
   VOID(pthread_mutex_lock(&LOCK_open));
   if (opt_log)
   {
     close_log_table(QUERY_LOG_GENERAL, TRUE);
-    query_cache_invalidate3(thd, close_general_log, 0);
-    unlock_table_name(thd, close_general_log);
+    query_cache_invalidate3(general_log_thd, &close_general_log, 0);
+    unlock_table_name(general_log_thd, &close_general_log);
   }
   if (opt_slow_log)
   {
     close_log_table(QUERY_LOG_SLOW, TRUE);
-    query_cache_invalidate3(thd, close_slow_log, 0);
-    unlock_table_name(thd, close_slow_log);
+    query_cache_invalidate3(general_log_thd, &close_slow_log, 0);
+    unlock_table_name(general_log_thd, &close_slow_log);
   }
   VOID(pthread_mutex_unlock(&LOCK_open));
-  /*
-    we use | and not || here, to ensure that both reopen_log_table
-    are called, even if the first one fails
-  */
-  if ((opt_slow_log && reopen_log_table(QUERY_LOG_SLOW)) |
-      (opt_log && reopen_log_table(QUERY_LOG_GENERAL)))
-    return 1;
-  return 0;
 }
 
 /* the parameters are unused for the log tables */

--- 1.119/sql/share/errmsg.txt	2006-09-07 11:30:58 +04:00
+++ 1.120/sql/share/errmsg.txt	2006-09-07 11:30:58 +04:00
@@ -5954,3 +5954,5 @@ ER_BAD_LOG_ENGINE
         eng "One can use only CSV and MyISAM engines for the log tables"
 ER_CANT_DROP_LOG_TABLE
         eng "Cannot drop log table if log is enabled"
+ER_CANT_RENAME_LOG_TABLE
+        eng "Cannot rename a log table. Rename of the log table is allowed only for log
rotate and in this case you should also specify a table with appropriate schema to be
renamed back to the log table"

--- 1.8/mysql-test/r/log_tables.result	2006-09-07 11:30:58 +04:00
+++ 1.9/mysql-test/r/log_tables.result	2006-09-07 11:30:58 +04:00
@@ -218,3 +218,36 @@ unlock tables;
 use mysql;
 lock tables general_log read local, help_category read local;
 unlock tables;
+use mysql;
+RENAME TABLE general_log TO renamed_general_log;
+ERROR HY000: Cannot rename a log table. Rename of the log table is allowed only for log
rotate and in this case you should also specify a table with appropriate schema to be
renamed back to the log table
+truncate table general_log;
+select * from general_log;
+event_time	user_host	thread_id	server_id	command_type	argument
+TIMESTAMP	USER_HOST	THREAD_ID	1	Query	select * from general_log
+create table general_log_new like general_log;
+Warnings:
+Error	1542	You can't write-lock a log table. Only read access is possible
+rename table general_log TO renamed_general_log, general_log_new TO general_log;
+rename table general_log TO general_log_new, renamed_general_log TO general_log, slow_log
to renamed_slow_log;
+ERROR HY000: Cannot rename a log table. Rename of the log table is allowed only for log
rotate and in this case you should also specify a table with appropriate schema to be
renamed back to the log table
+select * from general_log;
+event_time	user_host	thread_id	server_id	command_type	argument
+TIMESTAMP	USER_HOST	THREAD_ID	1	Query	rename table general_log TO general_log_new,
renamed_general_log TO general_log, slow_log to renamed_slow_log
+TIMESTAMP	USER_HOST	THREAD_ID	1	Query	select * from general_log
+select * from renamed_general_log;
+event_time	user_host	thread_id	server_id	command_type	argument
+TIMESTAMP	USER_HOST	THREAD_ID	1	Query	select * from general_log
+TIMESTAMP	USER_HOST	THREAD_ID	1	Query	create table general_log_new like general_log
+TIMESTAMP	USER_HOST	THREAD_ID	1	Query	SHOW WARNINGS
+TIMESTAMP	USER_HOST	THREAD_ID	1	Query	rename table general_log TO renamed_general_log,
general_log_new TO general_log
+set global general_log='OFF';
+RENAME TABLE general_log TO general_log2;
+set global general_log='ON';
+ERROR HY000: Cannot activate 'general' log
+RENAME TABLE general_log2 TO general_log;
+set global general_log='ON';
+flush logs;
+flush logs;
+drop table renamed_general_log;
+use test;

--- 1.12/mysql-test/t/log_tables.test	2006-09-07 11:30:58 +04:00
+++ 1.13/mysql-test/t/log_tables.test	2006-09-07 11:30:58 +04:00
@@ -314,6 +314,50 @@ use mysql;
 lock tables general_log read local, help_category read local;
 unlock tables;
 
+#
+# Bug #17544 Cannot do atomic log rotate and
+# Bug #21785  Server crashes after rename of the log table
+#
+
+use mysql;
+# Should result in error
+--error ER_CANT_RENAME_LOG_TABLE
+RENAME TABLE general_log TO renamed_general_log;
+#check rotate logs
+
+truncate table general_log;
+--replace_column 1 TIMESTAMP 2 USER_HOST 3 THREAD_ID
+select * from general_log;
+
+create table general_log_new like general_log;
+
+rename table general_log TO renamed_general_log, general_log_new TO general_log;
+# check that rename checks more then first table in the list
+--error ER_CANT_RENAME_LOG_TABLE
+rename table general_log TO general_log_new, renamed_general_log TO general_log, slow_log
to renamed_slow_log;
+
+--replace_column 1 TIMESTAMP 2 USER_HOST 3 THREAD_ID
+select * from general_log;
+
+--replace_column 1 TIMESTAMP 2 USER_HOST 3 THREAD_ID
+select * from renamed_general_log;
+
+# check that we can do whatever we want with disabled log
+set global general_log='OFF';
+RENAME TABLE general_log TO general_log2;
+# this should fail
+--error ER_CANT_ACTIVATE_LOG
+set global general_log='ON';
+RENAME TABLE general_log2 TO general_log;
+# this should work
+set global general_log='ON';
+# now check flush logs
+flush logs;
+flush logs;
+drop table renamed_general_log;
+use test;
+
+
 # kill all connections
 disconnect con1;
 disconnect con2;

--- 1.13/sql/log.h	2006-09-07 11:30:58 +04:00
+++ 1.14/sql/log.h	2006-09-07 11:30:58 +04:00
@@ -435,8 +435,7 @@ public:
                            const char *command_type, uint command_type_len,
                            const char *sql_text, uint sql_text_len,
                             CHARSET_INFO *client_cs);
-  bool flush(THD *thd, TABLE_LIST *close_slow_Log,
-             TABLE_LIST* close_general_log);
+  void close_n_lock_tables();
   void close_log_table(uint log_type, bool lock_in_use);
   bool reopen_log_table(uint log_type);
 };
@@ -497,6 +496,7 @@ public:
   {}
   void lock() { (void) pthread_mutex_lock(&LOCK_logger); }
   void unlock() { (void) pthread_mutex_unlock(&LOCK_logger); }
+  void close_n_lock_tables();
   bool is_general_log_table_enabled()
   {
     return table_log_handler && table_log_handler->general_log.table != 0;

--- 1.37/sql/sql_rename.cc	2006-09-07 11:30:58 +04:00
+++ 1.38/sql/sql_rename.cc	2006-09-07 11:30:58 +04:00
@@ -27,6 +27,26 @@ static TABLE_LIST *rename_tables(THD *th
 
 static TABLE_LIST *reverse_table_list(TABLE_LIST *table_list);
 
+
+/* Check if a given table is opened log table */
+int check_if_opened_log_table(uint db_len, const char *db,
+                              const char *table_name)
+{
+  if (db_len == 5 &&
+      !my_strcasecmp(system_charset_info, db, "mysql"))
+  {
+    if (!my_strcasecmp(system_charset_info, table_name, "general_log") &&
+        logger.is_general_log_table_enabled())
+      return QUERY_LOG_GENERAL;
+    else
+      if (!my_strcasecmp(system_charset_info, table_name, "slow_log") &&
+          logger.is_slow_log_table_enabled())
+        return QUERY_LOG_SLOW;
+  }
+  return 0;
+}
+
+
 /*
   Every second entry in the table_list is the original name and every
   second entry is the new name.
@@ -35,7 +55,8 @@ static TABLE_LIST *reverse_table_list(TA
 bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent)
 {
   bool error= 1;
-  TABLE_LIST *ren_table= 0;
+  TABLE_LIST *ren_table= 0, *new_table;
+  int disable_logs= 0;
   DBUG_ENTER("mysql_rename_tables");
 
   /*
@@ -52,6 +73,68 @@ bool mysql_rename_tables(THD *thd, TABLE
 
   if (wait_if_global_read_lock(thd,0,1))
     DBUG_RETURN(1);
+
+  if (logger.is_general_log_table_enabled() ||
+      logger.is_slow_log_table_enabled())
+  {
+
+    /*
+      Rules for rename of a log table:
+
+      IF   1. Log tables are enabled
+      AND  2. Rename operates on the log table and nothing is being
+              renamed to the log table.
+      DO   3. Throw an error message.
+      ELSE 4. Perform rename.
+    */
+
+    for (ren_table= table_list; ren_table; ren_table= new_table->next_local)
+    {
+      int log_table_rename= 0;
+      new_table= ren_table->next_local;
+
+      /*
+        If we found a log table, we need to make sure that there is another
+        table, which is renamed back to the log table.
+      */
+      if ((log_table_rename=
+           check_if_opened_log_table(ren_table->db_length,
+                                     ren_table->db, ren_table->table_name)))
+      {
+        TABLE_LIST *curr_table, *curr_new_table;
+
+        /*
+          Log table encoutered we will need to disable and lock logs
+          for duration of rename.
+        */
+        disable_logs= TRUE;
+
+        for (curr_table= new_table->next_local; curr_table;
+             curr_table= curr_new_table->next_local)
+        {
+          curr_new_table= curr_table->next_local;
+          if (log_table_rename ==
+              check_if_opened_log_table(curr_new_table->db_length,
+                                        curr_new_table->db,
+                                        curr_new_table->table_name))
+          {
+            log_table_rename= 0;
+            break;
+          }
+        }
+        if (log_table_rename)
+        {
+          my_error(ER_CANT_RENAME_LOG_TABLE, MYF(0));
+          DBUG_RETURN(1);
+        }
+      }
+    }
+
+    /* The function will close log tables and call logger.lock() */
+    if (disable_logs)
+      logger.close_n_lock_tables();
+  }
+
   VOID(pthread_mutex_lock(&LOCK_open));
   if (lock_table_names(thd, table_list))
     goto err;
@@ -95,6 +178,14 @@ bool mysql_rename_tables(THD *thd, TABLE
 
 err:
   pthread_mutex_unlock(&LOCK_open);
+  /* enable logging back if needed */
+  if (disable_logs)
+  {
+    if ((opt_slow_log && logger.reopen_log_table(QUERY_LOG_SLOW)) |
+        (opt_log && logger.reopen_log_table(QUERY_LOG_GENERAL)))
+      error= TRUE;
+    logger.unlock();
+  }
   start_waiting_global_read_lock(thd);
   DBUG_RETURN(error);
 }
Thread
bk commit into 5.1 tree (petr:1.2285) BUG#21785Petr Chardin7 Sep