MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:konstantin Date:June 11 2005 11:40am
Subject:bk commit into 4.1 tree (konstantin:1.2289) BUG#9141
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of kostja. When kostja 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
  1.2289 05/06/11 15:39:47 konstantin@stripped +4 -0
  A fix for Bug#9141 "4.1 does not log into slow log 
  ALTER, OPTIMIZE and ANALYZE statements".
  In 4.1 we disabled logging of slow admin commands. The fix adds an 
  option to enable it back.
  No test case (slow log is not tested in the test suite), but tested
  manually.

  sql/sql_parse.cc
    1.441 05/06/11 15:39:39 konstantin@stripped +18 -15
    Use opt_log_slow_admin_command to set slow logging for admin commands.

  sql/sql_class.h
    1.279 05/06/11 15:39:39 konstantin@stripped +1 -1
    Rename 'thd->slow_command' to thd->enable_slow_log_for_command (negates
    the meaning of this variable, and so resolves the need to negate
    value opt_log_slow_admin_command when setting it).

  sql/mysqld.cc
    1.575 05/06/11 15:39:39 konstantin@stripped +15 -3
    Add server option '--log-slow-admin-commands' to log slow
    optimize/alter/etc queries to the slow query log if it's enabled.
    Add warnings that this option works only if the slow query log is open.

  sql/mysql_priv.h
    1.351 05/06/11 15:39:39 konstantin@stripped +1 -0
    - declaration for a new option

# 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:	konstantin
# Host:	dragonfly.local
# Root:	/opt/local/work/mysql-4.1-9141

--- 1.350/sql/mysql_priv.h	2005-06-04 09:23:30 +04:00
+++ 1.351/sql/mysql_priv.h	2005-06-11 15:39:39 +04:00
@@ -918,6 +918,7 @@
 extern my_bool opt_readonly, lower_case_file_system;
 extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs;
 extern my_bool opt_secure_auth;
+extern my_bool opt_log_slow_admin_commands;
 extern uint opt_crash_binlog_innodb;
 extern char *shared_memory_base_name, *mysqld_unix_port;
 extern bool opt_enable_shared_memory;

--- 1.574/sql/mysqld.cc	2005-06-09 01:35:13 +04:00
+++ 1.575/sql/mysqld.cc	2005-06-11 15:39:39 +04:00
@@ -294,6 +294,7 @@
 my_bool opt_secure_auth= 0;
 my_bool opt_short_log_format= 0;
 my_bool opt_log_queries_not_using_indexes= 0;
+my_bool opt_log_slow_admin_commands= 0;
 my_bool lower_case_file_system= 0;
 my_bool opt_innodb_safe_binlog= 0;
 volatile bool mqh_used = 0;
@@ -4196,7 +4197,8 @@
   OPT_TIME_FORMAT,
   OPT_DATETIME_FORMAT,
   OPT_LOG_QUERIES_NOT_USING_INDEXES,
-  OPT_DEFAULT_TIME_ZONE
+  OPT_DEFAULT_TIME_ZONE,
+  OPT_LOG_SLOW_ADMIN_COMMANDS
 };
 
 
@@ -4456,7 +4458,7 @@
    "Log some extra information to update log. Please note that this option is deprecated; see --log-short-format option.", 
    0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"log-queries-not-using-indexes", OPT_LOG_QUERIES_NOT_USING_INDEXES,
-   "Log queries that are executed without benefit of any index.",
+   "Log queries that are executed without benefit of any index to the slow query log if it is open.",
    (gptr*) &opt_log_queries_not_using_indexes, (gptr*) &opt_log_queries_not_using_indexes,
    0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"log-short-format", OPT_SHORT_LOG_FORMAT,
@@ -4467,8 +4469,12 @@
    "Tells the slave to log the updates from the slave thread to the binary log. You will need to turn it on if you plan to daisy-chain the slaves.",
    (gptr*) &opt_log_slave_updates, (gptr*) &opt_log_slave_updates, 0, GET_BOOL,
    NO_ARG, 0, 0, 0, 0, 0, 0},
+  {"log-slow-admin-commands", OPT_LOG_SLOW_ADMIN_COMMANDS,
+   "Log slow OPTIMIZE, ANALYZE, ALTER and other administrative statements to the slow query log if it is open.",
+   (gptr*) &opt_log_slow_admin_commands, (gptr*) &opt_log_slow_admin_commands,
+   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"log-slow-queries", OPT_SLOW_QUERY_LOG,
-   "Log slow queries to this log file. Defaults logging to hostname-slow.log file.",
+    "Log slow queries to this log file. Defaults logging to hostname-slow.log file. Must be enabled to activate other slow query log options.",
    (gptr*) &opt_slow_logname, (gptr*) &opt_slow_logname, 0, GET_STR, OPT_ARG,
    0, 0, 0, 0, 0, 0},
   {"log-update", OPT_UPDATE_LOG,
@@ -6084,6 +6090,9 @@
   case (int) OPT_SLOW_QUERY_LOG:
     opt_slow_log=1;
     break;
+  case (int) OPT_LOG_SLOW_ADMIN_COMMANDS:
+    opt_log_slow_admin_commands= 1;
+    break;
   case (int) OPT_SKIP_NEW:
     opt_specialflag|= SPECIAL_NO_NEW_FUNC;
     delay_key_write_options= (uint) DELAY_KEY_WRITE_NONE;
@@ -6443,6 +6452,9 @@
   if (opt_bdb)
     sql_print_warning("this binary does not contain BDB storage engine");
 #endif
+  if ((opt_log_slow_admin_commands || opt_log_queries_not_using_indexes) &&
+      !opt_slow_log)
+    sql_print_warning("options --log-slow-admin-commands and --log-queries-not-using-indexes have no effect if --log-slow-queries is not set");
 
   /*
     Check that the default storage engine is actually available.

--- 1.278/sql/sql_class.h	2005-05-04 17:05:53 +04:00
+++ 1.279/sql/sql_class.h	2005-06-11 15:39:39 +04:00
@@ -916,7 +916,7 @@
   bool       query_error, bootstrap, cleanup_done;
   bool	     tmp_table_used;
   bool	     charset_is_system_charset, charset_is_collation_connection;
-  bool       slow_command;
+  bool       enable_slow_log_for_command;
   my_bool    volatile killed;
 
   /*

--- 1.440/sql/sql_parse.cc	2005-06-04 09:28:18 +04:00
+++ 1.441/sql/sql_parse.cc	2005-06-11 15:39:39 +04:00
@@ -1342,10 +1342,10 @@
 
   thd->command=command;
   /*
-    Commands which will always take a long time should be marked with
-    this so that they will not get logged to the slow query log
+    Commands which always take a long time are logged into the slow
+    query log only if opt_log_slow_admin_commands is set.
   */
-  thd->slow_command=FALSE;
+  thd->enable_slow_log_for_command= TRUE;
   thd->set_time();
   VOID(pthread_mutex_lock(&LOCK_thread_count));
   thd->query_id=query_id;
@@ -1383,7 +1383,7 @@
     uint tbl_len= *(uchar*) (packet + db_len + 1);
 
     statistic_increment(com_other, &LOCK_status);
-    thd->slow_command= TRUE;
+    thd->enable_slow_log_for_command= opt_log_slow_admin_commands;
     db= thd->alloc(db_len + tbl_len + 2);
     tbl_name= strmake(db, packet + 1, db_len)+1;
     strmake(tbl_name, packet + db_len + 2, tbl_len);
@@ -1658,7 +1658,7 @@
       uint32 slave_server_id;
 
       statistic_increment(com_other,&LOCK_status);
-      thd->slow_command = TRUE;
+      thd->enable_slow_log_for_command= opt_log_slow_admin_commands;
       if (check_global_access(thd, REPL_SLAVE_ACL))
 	break;
 
@@ -1848,8 +1848,11 @@
   time_t start_of_query=thd->start_time;
   thd->end_time();				// Set start time
 
-  /* If not reading from backup and if the query took too long */
-  if (!thd->slow_command && !thd->user_time) // do not log 'slow_command' queries
+  /*
+    Do not log admin commands unless the appropriate option is set;
+    do not log into slow log if reading from backup.
+  */
+  if (thd->enable_slow_log_for_command && !thd->user_time)
   {
     thd->proc_info="logging slow query";
 
@@ -2292,7 +2295,7 @@
 	check_table_access(thd,SELECT_ACL, tables,0) ||
 	check_global_access(thd, FILE_ACL))
       goto error; /* purecov: inspected */
-    thd->slow_command=TRUE;
+    thd->enable_slow_log_for_command= opt_log_slow_admin_commands;
     res = mysql_backup_table(thd, tables);
 
     break;
@@ -2303,7 +2306,7 @@
 	check_table_access(thd, INSERT_ACL, tables,0) ||
 	check_global_access(thd, FILE_ACL))
       goto error; /* purecov: inspected */
-    thd->slow_command=TRUE;
+    thd->enable_slow_log_for_command= opt_log_slow_admin_commands;
     res = mysql_restore_table(thd, tables);
     break;
   }
@@ -2524,7 +2527,7 @@
   case SQLCOM_CREATE_INDEX:
     if (check_one_table_access(thd, INDEX_ACL, tables))
       goto error; /* purecov: inspected */
-    thd->slow_command=TRUE;
+    thd->enable_slow_log_for_command= opt_log_slow_admin_commands;
     if (end_active_trans(thd))
       res= -1;
     else
@@ -2610,7 +2613,7 @@
 	res= -1;
       else
       {
-        thd->slow_command=TRUE;
+        thd->enable_slow_log_for_command= opt_log_slow_admin_commands;
 	res= mysql_alter_table(thd, select_lex->db, lex->name,
 			       &lex->create_info,
 			       tables, lex->create_list,
@@ -2702,7 +2705,7 @@
     if (check_db_used(thd,tables) ||
 	check_table_access(thd,SELECT_ACL | INSERT_ACL, tables,0))
       goto error; /* purecov: inspected */
-    thd->slow_command=TRUE;
+    thd->enable_slow_log_for_command= opt_log_slow_admin_commands;
     res = mysql_repair_table(thd, tables, &lex->check_opt);
     /* ! we write after unlocking the table */
     if (!res && !lex->no_write_to_binlog)
@@ -2722,7 +2725,7 @@
     if (check_db_used(thd,tables) ||
 	check_table_access(thd, SELECT_ACL | EXTRA_ACL , tables,0))
       goto error; /* purecov: inspected */
-    thd->slow_command=TRUE;
+    thd->enable_slow_log_for_command= opt_log_slow_admin_commands;
     res = mysql_check_table(thd, tables, &lex->check_opt);
     break;
   }
@@ -2731,7 +2734,7 @@
     if (check_db_used(thd,tables) ||
 	check_table_access(thd,SELECT_ACL | INSERT_ACL, tables,0))
       goto error; /* purecov: inspected */
-    thd->slow_command=TRUE;
+    thd->enable_slow_log_for_command= opt_log_slow_admin_commands;
     res = mysql_analyze_table(thd, tables, &lex->check_opt);
     /* ! we write after unlocking the table */
     if (!res && !lex->no_write_to_binlog)
@@ -2752,7 +2755,7 @@
     if (check_db_used(thd,tables) ||
 	check_table_access(thd,SELECT_ACL | INSERT_ACL, tables,0))
       goto error; /* purecov: inspected */
-    thd->slow_command=TRUE;
+    thd->enable_slow_log_for_command= opt_log_slow_admin_commands;
     res= (specialflag & (SPECIAL_SAFE_MODE | SPECIAL_NO_NEW_FUNC)) ?
       mysql_recreate_table(thd, tables, 1) :
       mysql_optimize_table(thd, tables, &lex->check_opt);
Thread
bk commit into 4.1 tree (konstantin:1.2289) BUG#9141konstantin11 Jun