diff options
author | Ramil Kalimullin <ramil@mysql.com> | 2010-12-07 20:08:54 +0300 |
---|---|---|
committer | Ramil Kalimullin <ramil@mysql.com> | 2010-12-07 20:08:54 +0300 |
commit | 7e4961bd51c5aefcaa9a5491dd99251343bc57b3 (patch) | |
tree | c696b862453a3634c852c69a8c823e445624e159 | |
parent | 6bad2a2a44328be23cbc4306408dcdbebfcd64f0 (diff) | |
download | mariadb-git-7e4961bd51c5aefcaa9a5491dd99251343bc57b3.tar.gz |
Fix for bug #58669: read_only not enforced on 5.5.x
merged from mysql-5.5.8-release tree,
revision: ramil@mysql.com-20101203174908-217tdkn150vieha9
-rw-r--r-- | mysql-test/r/bug58669.result | 17 | ||||
-rw-r--r-- | mysql-test/t/bug58669-master.opt | 1 | ||||
-rw-r--r-- | mysql-test/t/bug58669.test | 22 | ||||
-rw-r--r-- | sql/mysqld.cc | 5 | ||||
-rw-r--r-- | sql/mysqld.h | 3 | ||||
-rw-r--r-- | sql/sys_vars.cc | 11 |
6 files changed, 56 insertions, 3 deletions
diff --git a/mysql-test/r/bug58669.result b/mysql-test/r/bug58669.result new file mode 100644 index 00000000000..5504c5908be --- /dev/null +++ b/mysql-test/r/bug58669.result @@ -0,0 +1,17 @@ +# +# Bug#58669: read_only not enforced on 5.5.x +# +CREATE USER user1@localhost; +CREATE DATABASE db1; +GRANT ALL PRIVILEGES ON db1.* TO user1@localhost; +CREATE TABLE db1.t1(a INT); +SELECT CURRENT_USER(); +CURRENT_USER() +user1@localhost +SHOW VARIABLES LIKE "%read_only%"; +Variable_name Value +read_only ON +INSERT INTO db1.t1 VALUES (1); +ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement +DROP DATABASE db1; +DROP USER user1@localhost; diff --git a/mysql-test/t/bug58669-master.opt b/mysql-test/t/bug58669-master.opt new file mode 100644 index 00000000000..6d909680527 --- /dev/null +++ b/mysql-test/t/bug58669-master.opt @@ -0,0 +1 @@ +--read-only diff --git a/mysql-test/t/bug58669.test b/mysql-test/t/bug58669.test new file mode 100644 index 00000000000..332c104cfea --- /dev/null +++ b/mysql-test/t/bug58669.test @@ -0,0 +1,22 @@ +--source include/not_embedded.inc + +--echo # +--echo # Bug#58669: read_only not enforced on 5.5.x +--echo # + +CREATE USER user1@localhost; +CREATE DATABASE db1; +GRANT ALL PRIVILEGES ON db1.* TO user1@localhost; +CREATE TABLE db1.t1(a INT); + +connect (con1,localhost,user1,,); +connection con1; +SELECT CURRENT_USER(); +SHOW VARIABLES LIKE "%read_only%"; +--error ER_OPTION_PREVENTS_STATEMENT +INSERT INTO db1.t1 VALUES (1); + +connection default; +disconnect con1; +DROP DATABASE db1; +DROP USER user1@localhost; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 840962b2432..49523a5b007 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -410,7 +410,8 @@ handlerton *heap_hton; handlerton *myisam_hton; handlerton *partition_hton; -my_bool opt_readonly= 0, use_temp_pool, relay_log_purge; +my_bool read_only= 0, opt_readonly= 0; +my_bool use_temp_pool, relay_log_purge; my_bool relay_log_recovery; my_bool opt_sync_frm, opt_allow_suspicious_udfs; my_bool opt_secure_auth= 0; @@ -7349,6 +7350,8 @@ static int get_options(int *argc_ptr, char ***argv_ptr) test(global_system_variables.optimizer_switch & OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN); + opt_readonly= read_only; + return 0; } diff --git a/sql/mysqld.h b/sql/mysqld.h index 712b26382d1..5d8885ac277 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -107,7 +107,8 @@ extern my_bool opt_safe_show_db, opt_local_infile, opt_myisam_use_mmap; extern my_bool opt_slave_compressed_protocol, use_temp_pool; extern ulong slave_exec_mode_options; extern ulonglong slave_type_conversions_options; -extern my_bool opt_readonly, lower_case_file_system; +extern my_bool read_only, opt_readonly; +extern my_bool 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 char* opt_secure_file_priv; diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index ed2c44fb03f..68bb77d467f 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -1452,7 +1452,6 @@ static Sys_var_ulong Sys_read_buff_size( VALID_RANGE(IO_SIZE*2, INT_MAX32), DEFAULT(128*1024), BLOCK_SIZE(IO_SIZE)); -static my_bool read_only; static bool check_read_only(sys_var *self, THD *thd, set_var *var) { /* Prevent self dead-lock */ @@ -1536,6 +1535,16 @@ static bool fix_read_only(sys_var *self, THD *thd, enum_var_type type) read_only= opt_readonly; DBUG_RETURN(result); } + + +/** + The read_only boolean is always equal to the opt_readonly boolean except + during fix_read_only(); when that function is entered, opt_readonly is + the pre-update value and read_only is the post-update value. + fix_read_only() compares them and runs needed operations for the + transition (especially when transitioning from false to true) and + synchronizes both booleans in the end. +*/ static Sys_var_mybool Sys_readonly( "read_only", "Make all non-temporary tables read-only, with the exception for " |