diff options
author | Sergei Golubchik <serg@mariadb.org> | 2017-07-18 14:47:40 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2017-07-18 14:59:33 +0200 |
commit | 9b3360ea4417ed653d5c7eed29f4ef7e80618e43 (patch) | |
tree | ecd7b7db6547f5ad1e80dda928f79ee176f5efcf | |
parent | f6bcdb9e3c955f0a998a996edd93362deca31edf (diff) | |
download | mariadb-git-9b3360ea4417ed653d5c7eed29f4ef7e80618e43.tar.gz |
BUG#25250768: WRITING ON A READ_ONLY=ON SERVER WITHOUT SUPER PRIVILEGE
simplify.
add a test case.
-rw-r--r-- | mysql-test/r/read_only.result | 2 | ||||
-rw-r--r-- | mysql-test/t/read_only.test | 3 | ||||
-rw-r--r-- | sql/sql_parse.cc | 26 |
3 files changed, 14 insertions, 17 deletions
diff --git a/mysql-test/r/read_only.result b/mysql-test/r/read_only.result index 1ffe2b86f70..807dc426696 100644 --- a/mysql-test/r/read_only.result +++ b/mysql-test/r/read_only.result @@ -30,6 +30,8 @@ create temporary table t3 (a int); create temporary table t4 (a int) select * from t3; insert into t3 values(1); insert into t4 select * from t3; +create table t3 (a int); +ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement update t1,t3 set t1.a=t3.a+1 where t1.a=t3.a; ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement update t1,t3 set t3.a=t1.a+1 where t1.a=t3.a; diff --git a/mysql-test/t/read_only.test b/mysql-test/t/read_only.test index 52349747883..a0bd7b49273 100644 --- a/mysql-test/t/read_only.test +++ b/mysql-test/t/read_only.test @@ -80,6 +80,9 @@ insert into t3 values(1); insert into t4 select * from t3; +--error ER_OPTION_PREVENTS_STATEMENT +create table t3 (a int); + # a non-temp table updated: --error ER_OPTION_PREVENTS_STATEMENT update t1,t3 set t1.a=t3.a+1 where t1.a=t3.a; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 83cd6cccba5..1d596ed9df7 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -835,24 +835,16 @@ static my_bool deny_updates_if_read_only_option(THD *thd, if (lex->sql_command == SQLCOM_UPDATE_MULTI) DBUG_RETURN(FALSE); - const my_bool create_temp_tables= - (lex->sql_command == SQLCOM_CREATE_TABLE) && - (lex->create_info.options & HA_LEX_CREATE_TMP_TABLE); - - const my_bool create_real_tables= - (lex->sql_command == SQLCOM_CREATE_TABLE) && - !(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE); - - const my_bool drop_temp_tables= - (lex->sql_command == SQLCOM_DROP_TABLE) && - lex->drop_temporary; - - const my_bool update_real_tables= - ((create_real_tables || - some_non_temp_table_to_be_updated(thd, all_tables)) && - !(create_temp_tables || drop_temp_tables)); + /* + a table-to-be-created is not in the temp table list yet, + so CREATE TABLE needs a special treatment + */ + const bool update_real_tables= + lex->sql_command == SQLCOM_CREATE_TABLE + ? !(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) + : some_non_temp_table_to_be_updated(thd, all_tables); - const my_bool create_or_drop_databases= + const bool create_or_drop_databases= (lex->sql_command == SQLCOM_CREATE_DB) || (lex->sql_command == SQLCOM_DROP_DB); |