Commit 99f4b743 authored by kaa@polly.(none)'s avatar kaa@polly.(none)
Browse files

Fix for bug #29131: SHOW VARIABLES reports variable 'log' but SET

doesn't recognize it

This is a 5.0 version of the patch, it will be null-merged to 5.1

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:

Make 'log' and 'log_slow_queries' read-only dynamic variables to make 
them available for use in expressions, and produce a correct error 
about the variable being read-only when used in the SET statement.
parent 34984111
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -791,6 +791,22 @@ ERROR HY000: Variable 'hostname' is a read only variable
show variables like 'hostname';
Variable_name	Value
hostname	#
SHOW VARIABLES LIKE 'log';
Variable_name	Value
log	ON
SELECT @@log;
@@log
1
SET GLOBAL log=0;
ERROR HY000: Variable 'log' is a read only variable
SHOW VARIABLES LIKE 'log_slow_queries';
Variable_name	Value
log_slow_queries	ON
SELECT @@log_slow_queries;
@@log_slow_queries
1
SET GLOBAL log_slow_queries=0;
ERROR HY000: Variable 'log_slow_queries' is a read only variable
End of 5.0 tests
set global binlog_cache_size         =@my_binlog_cache_size;
set global connect_timeout           =@my_connect_timeout;
+14 −0
Original line number Diff line number Diff line
@@ -674,6 +674,20 @@ set @@hostname= "anothername";
--replace_column 2 #
show variables like 'hostname';

#
# Bug #29131: SHOW VARIABLES reports variable 'log' but SET doesn't recognize it
#

SHOW VARIABLES LIKE 'log';
SELECT @@log;
--error 1238
SET GLOBAL log=0;

SHOW VARIABLES LIKE 'log_slow_queries';
SELECT @@log_slow_queries;
--error 1238
SET GLOBAL log_slow_queries=0;

--echo End of 5.0 tests

# This is at the very after the versioned tests, since it involves doing
+2 −2
Original line number Diff line number Diff line
@@ -1306,8 +1306,8 @@ extern bool opt_endinfo, using_udf_functions;
extern my_bool locked_in_memory;
extern bool opt_using_transactions, mysqld_embedded;
extern bool using_update_log, opt_large_files, server_id_supplied;
extern bool opt_log, opt_update_log, opt_bin_log, opt_slow_log, opt_error_log;
extern my_bool opt_log_queries_not_using_indexes;
extern bool opt_update_log, opt_bin_log, opt_error_log;
extern my_bool opt_log, opt_slow_log, opt_log_queries_not_using_indexes;
extern bool opt_disable_networking, opt_skip_show_db;
extern my_bool opt_character_set_client_handshake;
extern bool volatile abort_loop, shutdown_in_progress, grant_option;
+2 −2
Original line number Diff line number Diff line
@@ -339,8 +339,8 @@ static my_bool opt_sync_bdb_logs;

/* Global variables */

bool opt_log, opt_update_log, opt_bin_log, opt_slow_log;
my_bool opt_log_queries_not_using_indexes= 0;
bool opt_update_log, opt_bin_log;
my_bool opt_log, opt_slow_log, opt_log_queries_not_using_indexes= 0;
bool opt_error_log= IF_WIN(1,0);
bool opt_disable_networking=0, opt_skip_show_db=0;
my_bool opt_character_set_client_handshake= 1;
+6 −2
Original line number Diff line number Diff line
@@ -201,6 +201,7 @@ sys_var_key_cache_long sys_key_cache_age_threshold("key_cache_age_threshold",
							      param_age_threshold));
sys_var_bool_ptr	sys_local_infile("local_infile",
					 &opt_local_infile);
sys_var_bool_const_ptr sys_log("log", &opt_log);
sys_var_trust_routine_creators
sys_trust_routine_creators("log_bin_trust_routine_creators",
                           &trust_function_creators);
@@ -213,6 +214,7 @@ sys_var_bool_ptr
sys_var_thd_ulong	sys_log_warnings("log_warnings", &SV::log_warnings);
sys_var_thd_ulong	sys_long_query_time("long_query_time",
					     &SV::long_query_time);
sys_var_bool_const_ptr sys_log_slow("log_slow_queries", &opt_slow_log);
sys_var_thd_bool	sys_low_priority_updates("low_priority_updates",
						 &SV::low_priority_updates,
						 fix_low_priority_updates);
@@ -665,9 +667,11 @@ sys_var *sys_variables[]=
  &sys_lc_time_names,
  &sys_license,
  &sys_local_infile,
  &sys_log,
  &sys_log_binlog,
  &sys_log_off,
  &sys_log_queries_not_using_indexes,
  &sys_log_slow,
  &sys_log_update,
  &sys_log_warnings,
  &sys_long_query_time,
@@ -946,7 +950,7 @@ struct show_var_st init_vars[]= {
#ifdef HAVE_MLOCKALL
  {"locked_in_memory",	      (char*) &locked_in_memory,	    SHOW_BOOL},
#endif
  {"log",                     (char*) &opt_log,                     SHOW_BOOL},
  {sys_log.name,              (char*) &sys_log,                     SHOW_SYS},
  {"log_bin",                 (char*) &opt_bin_log,                 SHOW_BOOL},
  {sys_trust_function_creators.name,(char*) &sys_trust_function_creators, SHOW_SYS},
  {"log_error",               (char*) log_error_file,               SHOW_CHAR},
@@ -955,7 +959,7 @@ struct show_var_st init_vars[]= {
#ifdef HAVE_REPLICATION
  {"log_slave_updates",       (char*) &opt_log_slave_updates,       SHOW_MY_BOOL},
#endif
  {"log_slow_queries",        (char*) &opt_slow_log,                SHOW_BOOL},
  {sys_log_slow.name,         (char*) &sys_log_slow,                SHOW_SYS},
  {sys_log_warnings.name,     (char*) &sys_log_warnings,	    SHOW_SYS},
  {sys_long_query_time.name,  (char*) &sys_long_query_time, 	    SHOW_SYS},
  {sys_low_priority_updates.name, (char*) &sys_low_priority_updates, SHOW_SYS},
Loading