Commit 9b3360ea authored by Sergei Golubchik's avatar Sergei Golubchik

BUG#25250768: WRITING ON A READ_ONLY=ON SERVER WITHOUT SUPER PRIVILEGE

simplify.
add a test case.
parent f6bcdb9e
......@@ -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;
......
......@@ -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;
......
......@@ -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);
......
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