List:Commits« Previous MessageNext Message »
From:marc.alff Date:July 27 2007 6:19pm
Subject:bk commit into 5.1 tree (malff:1.2554)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of marcsql. When marcsql 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-07-27 12:19:36-06:00, malff@weblab.(none) +5 -0
  Code review changes

  sql/handler.cc@stripped, 2007-07-27 12:19:33-06:00, malff@weblab.(none) +2 -0
    Code review changes

  sql/lock.cc@stripped, 2007-07-27 12:19:33-06:00, malff@weblab.(none) +30 -11
    Code review changes

  sql/log.cc@stripped, 2007-07-27 12:19:33-06:00, malff@weblab.(none) +17 -25
    Code review changes

  sql/log.h@stripped, 2007-07-27 12:19:33-06:00, malff@weblab.(none) +0 -3
    Code review changes

  sql/sql_parse.cc@stripped, 2007-07-27 12:19:33-06:00, malff@weblab.(none) +1 -1
    Code review changes

diff -Nrup a/sql/handler.cc b/sql/handler.cc
--- a/sql/handler.cc	2007-07-26 18:26:39 -06:00
+++ b/sql/handler.cc	2007-07-27 12:19:33 -06:00
@@ -3658,6 +3658,8 @@ int handler::ha_write_row(uchar *buf)
   Write a record to the engine bypassing row-level binary logging.
   This method is used internally by the server for writing to
   performance schema tables, which are never replicated.
+  TODO: Merge this function with ha_write_row(), and provide a way
+  to disable the binlog there.
 */
 int handler::ha_write_row_no_binlog(uchar *buf)
 {
diff -Nrup a/sql/lock.cc b/sql/lock.cc
--- a/sql/lock.cc	2007-07-26 18:26:39 -06:00
+++ b/sql/lock.cc	2007-07-27 12:19:33 -06:00
@@ -111,21 +111,23 @@ static void print_lock_error(int error, 
 static int thr_lock_errno_to_mysql[]=
 { 0, 1, ER_LOCK_WAIT_TIMEOUT, ER_LOCK_DEADLOCK };
 
-MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count,
-                              uint flags, bool *need_reopen)
+/**
+  Perform semantic checks for mysql_lock_tables.
+  @param thd The current thread
+  @param tables The tables to lock
+  @param count The number of tables to lock
+  @param flags Lock flags
+  @return 0 if all the check passed, non zero if a check failed.
+*/
+int mysql_lock_tables_check(THD *thd, TABLE **tables, uint count, uint flags)
 {
-  MYSQL_LOCK *sql_lock;
-  TABLE *write_lock_used;
-  int rc;
-  uint i;
   bool log_table_write_query;
   uint system_count;
+  uint i;
 
-  DBUG_ENTER("mysql_lock_tables");
+  DBUG_ENTER("mysql_lock_tables_check");
 
-  *need_reopen= FALSE;
   system_count= 0;
-
   log_table_write_query= (is_log_table_write_query(thd->lex->sql_command)
                          || ((flags & MYSQL_LOCK_PERF_SCHEMA) != 0));
 
@@ -154,7 +156,7 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, 
           || (thd->lex->sql_command == SQLCOM_LOCK_TABLES))
       {
         my_error(ER_CANT_LOCK_LOG_TABLE, MYF(0));
-        DBUG_RETURN(0);
+        DBUG_RETURN(1);
       }
     }
 
@@ -173,8 +175,25 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, 
   if ((system_count > 0) && (system_count < count))
   {
     my_error(ER_WRONG_LOCK_OF_SYSTEM_TABLE, MYF(0));
-    DBUG_RETURN(0);
+    DBUG_RETURN(1);
   }
+
+  DBUG_RETURN(0);
+}
+
+MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count,
+                              uint flags, bool *need_reopen)
+{
+  MYSQL_LOCK *sql_lock;
+  TABLE *write_lock_used;
+  int rc;
+
+  DBUG_ENTER("mysql_lock_tables");
+
+  *need_reopen= FALSE;
+
+  if (mysql_lock_tables_check(thd, tables, count, flags))
+    DBUG_RETURN (NULL);
 
   for (;;)
   {
diff -Nrup a/sql/log.cc b/sql/log.cc
--- a/sql/log.cc	2007-07-26 18:26:39 -06:00
+++ b/sql/log.cc	2007-07-27 12:19:33 -06:00
@@ -708,19 +708,10 @@ bool Log_to_file_event_handler::
            longlong query_time, longlong lock_time, bool is_command,
            const char *sql_text, uint sql_text_len)
 {
-  bool res;
-
-  (void) pthread_mutex_lock(mysql_slow_log.get_log_lock());
-
-  /* TODO: MYSQL_QUERY_LOG::write is not thread-safe */
-  res= mysql_slow_log.write(thd, current_time, query_start_arg,
-                            user_host, user_host_len,
-                            query_time, lock_time, is_command,
-                            sql_text, sql_text_len);
-
-  (void) pthread_mutex_unlock(mysql_slow_log.get_log_lock());
-
-  return res;
+  return mysql_slow_log.write(thd, current_time, query_start_arg,
+                              user_host, user_host_len,
+                              query_time, lock_time, is_command,
+                              sql_text, sql_text_len);
 }
 
 
@@ -736,18 +727,9 @@ bool Log_to_file_event_handler::
               const char *sql_text, uint sql_text_len,
               CHARSET_INFO *client_cs)
 {
-  bool res;
-
-  (void) pthread_mutex_lock (mysql_log.get_log_lock());
-
-  /* TODO: MYSQL_QUERY_LOG::write is not thread-safe */
-  res= mysql_log.write(event_time, user_host, user_host_len,
-                       thread_id, command_type, command_type_len,
-                       sql_text, sql_text_len);
-
-  (void) pthread_mutex_unlock (mysql_log.get_log_lock());
-
-  return res;
+  return mysql_log.write(event_time, user_host, user_host_len,
+                         thread_id, command_type, command_type_len,
+                         sql_text, sql_text_len);
 }
 
 
@@ -1959,6 +1941,8 @@ bool MYSQL_QUERY_LOG::write(time_t event
   struct tm start;
   uint time_buff_len= 0;
 
+  (void) pthread_mutex_lock(&LOCK_log);
+
   /* Test if someone closed between the is_open test and lock */
   if (is_open())
   {
@@ -2003,6 +1987,7 @@ bool MYSQL_QUERY_LOG::write(time_t event
       goto err;
   }
 
+  (void) pthread_mutex_unlock(&LOCK_log);
   return FALSE;
 err:
 
@@ -2011,6 +1996,7 @@ err:
     write_error= 1;
     sql_print_error(ER(ER_ERROR_ON_WRITE), name, errno);
   }
+  (void) pthread_mutex_unlock(&LOCK_log);
   return TRUE;
 }
 
@@ -2053,8 +2039,13 @@ bool MYSQL_QUERY_LOG::write(THD *thd, ti
   bool error= 0;
   DBUG_ENTER("MYSQL_QUERY_LOG::write");
 
+  (void) pthread_mutex_lock(&LOCK_log);
+
   if (!is_open())
+  {
+    (void) pthread_mutex_unlock(&LOCK_log);
     DBUG_RETURN(0);
+  }
 
   if (is_open())
   {						// Safety agains reopen
@@ -2158,6 +2149,7 @@ bool MYSQL_QUERY_LOG::write(THD *thd, ti
       }
     }
   }
+  (void) pthread_mutex_unlock(&LOCK_log);
   DBUG_RETURN(error);
 }
 
diff -Nrup a/sql/log.h b/sql/log.h
--- a/sql/log.h	2007-07-26 18:26:39 -06:00
+++ b/sql/log.h	2007-07-27 12:19:33 -06:00
@@ -213,9 +213,6 @@ public:
                 WRITE_CACHE);
   }
 
-  /* TODO: fix MYSQL_LOG::write to be thread safe instead. */
-  inline pthread_mutex_t* get_log_lock() { return &LOCK_log; }
-
 private:
   time_t last_time;
 };
diff -Nrup a/sql/sql_parse.cc b/sql/sql_parse.cc
--- a/sql/sql_parse.cc	2007-07-26 18:26:40 -06:00
+++ b/sql/sql_parse.cc	2007-07-27 12:19:33 -06:00
@@ -210,7 +210,7 @@ void init_update_queries(void)
   sql_command_flags[SQLCOM_CREATE_VIEW]=    CF_CHANGES_DATA;
   sql_command_flags[SQLCOM_DROP_VIEW]=      CF_CHANGES_DATA;
   sql_command_flags[SQLCOM_CREATE_EVENT]=   CF_CHANGES_DATA;
-  sql_command_flags[SQLCOM_ALTER_EVENT]=    CF_CHANGES_DATA | CF_WRITE_LOGS_COMMAND;
+  sql_command_flags[SQLCOM_ALTER_EVENT]=    CF_CHANGES_DATA;
   sql_command_flags[SQLCOM_DROP_EVENT]=     CF_CHANGES_DATA;
 
   sql_command_flags[SQLCOM_UPDATE]=	    CF_CHANGES_DATA | CF_HAS_ROW_COUNT;
Thread
bk commit into 5.1 tree (malff:1.2554)marc.alff31 Jul