List:Commits« Previous MessageNext Message »
From:Alexey Kopytov Date:October 25 2007 10:03am
Subject:bk commit into 5.1 tree (kaa:1.2588) BUG#29131
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of kaa. When kaa 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-10-25 14:03:24+04:00, kaa@polly.(none) +3 -0
  Fix for bug #29131: SHOW VARIABLES reports variable 'log' but SET
  doesn't recognize it
    
  This is a 5.1 version of the patch.
    
  Problem:
    
  'log' and 'log_slow_queries' were "fixed" variables, i.e. they showed up
  in SHOW VARIABLES, but could not be used in expressions like 
  "select @@log". Also, using them in the SET statement produced an 
  incorrect "unknown system variable" error.
    
  Solution:
  
  Since as of MySQL 5.1.12 one can enable or disable the general query log
  or the slow query log at runtime by changing values of
  general_log/slow_query_log, make 'log' and 'log_slow_queries" to be 
  synonyms for 'general_log' and 'slow_query_log' respectively.  This 
  makes expressions using the '@@var' syntax backward compatible with 
  5.0 and SHOW VARIABLES output to be consistent with the SET statement.

  mysql-test/r/log_state.result@stripped, 2007-10-25 14:03:17+04:00, kaa@polly.(none) +63 -0
    Added a test case for bug #29131.

  mysql-test/t/log_state.test@stripped, 2007-10-25 14:03:17+04:00, kaa@polly.(none) +36 -0
    Added a test case for bug #29131.

  sql/set_var.cc@stripped, 2007-10-25 14:03:17+04:00, kaa@polly.(none) +6 -2
    Made the 'log' and 'log_slow_queries' system variables to be synonyms for 'general_log' and 'slow_query_log'.

diff -Nrup a/mysql-test/r/log_state.result b/mysql-test/r/log_state.result
--- a/mysql-test/r/log_state.result	2007-08-08 15:49:17 +04:00
+++ b/mysql-test/r/log_state.result	2007-10-25 14:03:17 +04:00
@@ -175,3 +175,66 @@ SET GLOBAL slow_query_log = ON;
 SET GLOBAL READ_ONLY = OFF;
 SET GLOBAL general_log = @old_general_log_state;
 SET GLOBAL slow_query_log = @old_slow_log_state;
+SET @old_general_log_state = @@global.general_log;
+SET @old_slow_log_state = @@global.slow_query_log;
+SHOW VARIABLES LIKE 'general_log';
+Variable_name	Value
+general_log	ON
+SHOW VARIABLES LIKE 'log';
+Variable_name	Value
+log	ON
+SELECT @@general_log, @@log;
+@@general_log	@@log
+1	1
+SET GLOBAL log = 0;
+SHOW VARIABLES LIKE 'general_log';
+Variable_name	Value
+general_log	OFF
+SHOW VARIABLES LIKE 'log';
+Variable_name	Value
+log	OFF
+SELECT @@general_log, @@log;
+@@general_log	@@log
+0	0
+SET GLOBAL general_log = 1;
+SHOW VARIABLES LIKE 'general_log';
+Variable_name	Value
+general_log	ON
+SHOW VARIABLES LIKE 'log';
+Variable_name	Value
+log	ON
+SELECT @@general_log, @@log;
+@@general_log	@@log
+1	1
+SHOW VARIABLES LIKE 'slow_query_log';
+Variable_name	Value
+slow_query_log	OFF
+SHOW VARIABLES LIKE 'log_slow_queries';
+Variable_name	Value
+log_slow_queries	OFF
+SELECT @@slow_query_log, @@log_slow_queries;
+@@slow_query_log	@@log_slow_queries
+0	0
+SET GLOBAL log_slow_queries = 0;
+SHOW VARIABLES LIKE 'slow_query_log';
+Variable_name	Value
+slow_query_log	OFF
+SHOW VARIABLES LIKE 'log_slow_queries';
+Variable_name	Value
+log_slow_queries	OFF
+SELECT @@slow_query_log, @@log_slow_queries;
+@@slow_query_log	@@log_slow_queries
+0	0
+SET GLOBAL slow_query_log = 1;
+SHOW VARIABLES LIKE 'slow_query_log';
+Variable_name	Value
+slow_query_log	ON
+SHOW VARIABLES LIKE 'log_slow_queries';
+Variable_name	Value
+log_slow_queries	ON
+SELECT @@slow_query_log, @@log_slow_queries;
+@@slow_query_log	@@log_slow_queries
+1	1
+SET GLOBAL general_log = @old_general_log_state;
+SET GLOBAL slow_query_log = @old_slow_log_state;
+End of 5.1 tests
diff -Nrup a/mysql-test/t/log_state.test b/mysql-test/t/log_state.test
--- a/mysql-test/t/log_state.test	2007-08-08 15:49:17 +04:00
+++ b/mysql-test/t/log_state.test	2007-10-25 14:03:17 +04:00
@@ -179,6 +179,42 @@ SET GLOBAL READ_ONLY = OFF;
 SET GLOBAL general_log = @old_general_log_state;
 SET GLOBAL slow_query_log = @old_slow_log_state;
 
+#
+# Bug #29131: SHOW VARIABLES reports variable 'log' but SET doesn't recognize it
+#
+
+SET @old_general_log_state = @@global.general_log;
+SET @old_slow_log_state = @@global.slow_query_log;
+
+SHOW VARIABLES LIKE 'general_log';
+SHOW VARIABLES LIKE 'log';
+SELECT @@general_log, @@log;
+SET GLOBAL log = 0;
+SHOW VARIABLES LIKE 'general_log';
+SHOW VARIABLES LIKE 'log';
+SELECT @@general_log, @@log;
+SET GLOBAL general_log = 1;
+SHOW VARIABLES LIKE 'general_log';
+SHOW VARIABLES LIKE 'log';
+SELECT @@general_log, @@log;
+
+SHOW VARIABLES LIKE 'slow_query_log';
+SHOW VARIABLES LIKE 'log_slow_queries';
+SELECT @@slow_query_log, @@log_slow_queries;
+SET GLOBAL log_slow_queries = 0;
+SHOW VARIABLES LIKE 'slow_query_log';
+SHOW VARIABLES LIKE 'log_slow_queries';
+SELECT @@slow_query_log, @@log_slow_queries;
+SET GLOBAL slow_query_log = 1;
+SHOW VARIABLES LIKE 'slow_query_log';
+SHOW VARIABLES LIKE 'log_slow_queries';
+SELECT @@slow_query_log, @@log_slow_queries;
+
+SET GLOBAL general_log = @old_general_log_state;
+SET GLOBAL slow_query_log = @old_slow_log_state;
+
+--echo End of 5.1 tests
+
 --enable_ps_protocol
 
 #
diff -Nrup a/sql/set_var.cc b/sql/set_var.cc
--- a/sql/set_var.cc	2007-10-10 11:35:47 +04:00
+++ b/sql/set_var.cc	2007-10-25 14:03:17 +04:00
@@ -641,8 +641,14 @@ static sys_var_const_str	sys_license(&va
 /* Global variables which enable|disable logging */
 static sys_var_log_state sys_var_general_log(&vars, "general_log", &opt_log,
                                       QUERY_LOG_GENERAL);
+/* Synonym of "general_log" for consistency with SHOW VARIABLES output */
+static sys_var_log_state sys_var_log(&vars, "log", &opt_log,
+                                      QUERY_LOG_GENERAL);
 static sys_var_log_state sys_var_slow_query_log(&vars, "slow_query_log", &opt_slow_log,
                                          QUERY_LOG_SLOW);
+/* Synonym of "slow_query_log" for consistency with SHOW VARIABLES output */
+static sys_var_log_state sys_var_log_slow(&vars, "log_slow_queries",
+                                          &opt_slow_log, QUERY_LOG_SLOW);
 sys_var_str sys_var_general_log_path(&vars, "general_log_file", sys_check_log_path,
 				     sys_update_general_log_path,
 				     sys_default_general_log_path,
@@ -678,10 +684,8 @@ static SHOW_VAR fixed_vars[]= {
 #ifdef HAVE_MLOCKALL
   {"locked_in_memory",	      (char*) &locked_in_memory,	    SHOW_MY_BOOL},
 #endif
-  {"log",                     (char*) &opt_log,                     SHOW_MY_BOOL},
   {"log_bin",                 (char*) &opt_bin_log,                 SHOW_BOOL},
   {"log_error",               (char*) log_error_file,               SHOW_CHAR},
-  {"log_slow_queries",        (char*) &opt_slow_log,                SHOW_MY_BOOL},
   {"lower_case_file_system",  (char*) &lower_case_file_system,      SHOW_MY_BOOL},
   {"lower_case_table_names",  (char*) &lower_case_table_names,      SHOW_INT},
   {"myisam_recover_options",  (char*) &myisam_recover_options_str,  SHOW_CHAR_PTR},
Thread
bk commit into 5.1 tree (kaa:1.2588) BUG#29131Alexey Kopytov25 Oct