Commit a6457ad2 authored by unknown's avatar unknown

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:
  Added a test case for bug #29131.
mysql-test/t/log_state.test:
  Added a test case for bug #29131.
sql/set_var.cc:
  Made the 'log' and 'log_slow_queries' system variables to be synonyms for 'general_log' and 'slow_query_log'.
parent 87784bf6
......@@ -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
......@@ -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
#
......
......@@ -641,8 +641,14 @@ static sys_var_const_str sys_license(&vars, "license", STRINGIFY_ARG(LICENSE));
/* 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},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment