Below is the list of changes that have just been committed into a local
5.0 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:02:27+04:00, kaa@polly.(none) +6 -0
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.
mysql-test/r/variables.result@stripped, 2007-10-25 14:02:22+04:00, kaa@polly.(none) +16 -0
Added a test case for bug #29131.
mysql-test/t/variables.test@stripped, 2007-10-25 14:02:23+04:00, kaa@polly.(none) +14 -0
Added a test case for bug #29131.
sql/mysql_priv.h@stripped, 2007-10-25 14:02:23+04:00, kaa@polly.(none) +2 -2
Changed the type of opt_log and opt_slow_log to my_bool to
align with the interfaces in set_var.cc
sql/mysqld.cc@stripped, 2007-10-25 14:02:23+04:00, kaa@polly.(none) +2 -2
Changed the type of opt_log and opt_slow_log to my_bool to
align with the interfaces in set_var.cc
sql/set_var.cc@stripped, 2007-10-25 14:02:23+04:00, kaa@polly.(none) +6 -2
Made 'log' and 'log_slow_queries' to be read-only dynamic system
variable, i.e. available for use in expressions with the @@var syntax.
sql/set_var.h@stripped, 2007-10-25 14:02:23+04:00, kaa@polly.(none) +22 -0
Added a new system variable class representing a read-only boolean
variable.
diff -Nrup a/mysql-test/r/variables.result b/mysql-test/r/variables.result
--- a/mysql-test/r/variables.result 2007-04-09 16:58:53 +04:00
+++ b/mysql-test/r/variables.result 2007-10-25 14:02:22 +04:00
@@ -791,6 +791,22 @@ ERROR HY000: Variable 'hostname' is a re
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;
diff -Nrup a/mysql-test/t/variables.test b/mysql-test/t/variables.test
--- a/mysql-test/t/variables.test 2007-04-09 16:58:53 +04:00
+++ b/mysql-test/t/variables.test 2007-10-25 14:02:23 +04:00
@@ -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
diff -Nrup a/sql/mysql_priv.h b/sql/mysql_priv.h
--- a/sql/mysql_priv.h 2007-09-22 11:48:35 +04:00
+++ b/sql/mysql_priv.h 2007-10-25 14:02:23 +04:00
@@ -1306,8 +1306,8 @@ extern bool opt_endinfo, using_udf_funct
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;
diff -Nrup a/sql/mysqld.cc b/sql/mysqld.cc
--- a/sql/mysqld.cc 2007-08-16 18:25:45 +04:00
+++ b/sql/mysqld.cc 2007-10-25 14:02:23 +04:00
@@ -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;
diff -Nrup a/sql/set_var.cc b/sql/set_var.cc
--- a/sql/set_var.cc 2007-10-10 11:21:10 +04:00
+++ b/sql/set_var.cc 2007-10-25 14:02:23 +04:00
@@ -201,6 +201,7 @@ sys_var_key_cache_long sys_key_cache_ag
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},
diff -Nrup a/sql/set_var.h b/sql/set_var.h
--- a/sql/set_var.h 2007-02-21 14:05:01 +03:00
+++ b/sql/set_var.h 2007-10-25 14:02:23 +04:00
@@ -160,6 +160,28 @@ public:
};
+class sys_var_bool_const_ptr : public sys_var
+{
+public:
+ my_bool *value;
+ sys_var_bool_const_ptr(const char *name_arg, my_bool *value_arg)
+ :sys_var(name_arg),value(value_arg)
+ {}
+ bool check(THD *thd, set_var *var)
+ {
+ return 1;
+ }
+ bool update(THD *thd, set_var *var)
+ {
+ return 1;
+ }
+ SHOW_TYPE show_type() { return SHOW_MY_BOOL; }
+ byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
+ { return (byte*) value; }
+ bool check_update_type(Item_result type) { return 0; }
+ bool is_readonly() const { return 1; }
+};
+
class sys_var_str :public sys_var
{
public:
| Thread |
|---|
| • bk commit into 5.0 tree (kaa:1.2547) BUG#29131 | Alexey Kopytov | 25 Oct |