Commit 346033a5 authored by kaa@polly.local's avatar kaa@polly.local

Fix for bug #22077 "DROP TEMPORARY TABLE fails with wrong error if read_only is set"

Do not issue a 'read-only' error in case of DROP TEMPORARY TABLE on a non-existing temporary table.
Instead produce the correct "Unknown table" error or warning (in cases when the IF EXISTS clause was specified).

To a documentor: the part of the manual describing the 'read_only' system variable should be clarified to state the following:
"When the read_only variable is set to ON, all operations which create/update/drop tables are rejected with the exceptions for:
1. Any operation performed by the replication thread on a slave server
2. Any operation performed by a user that have the SUPER privilege
3. Any operation that creates/updates/drops only temporary tables"
parent 8471897f
...@@ -39,6 +39,11 @@ delete t1 from t1,t3 where t1.a=t3.a; ...@@ -39,6 +39,11 @@ delete t1 from t1,t3 where t1.a=t3.a;
drop table t1; drop table t1;
insert into t1 values(1); insert into t1 values(1);
ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement
drop temporary table ttt;
ERROR 42S02: Unknown table 'ttt'
drop temporary table if exists ttt;
Warnings:
Note 1051 Unknown table 'ttt'
drop table t1,t2; drop table t1,t2;
drop user test@localhost; drop user test@localhost;
set global read_only=0; set global read_only=0;
...@@ -101,6 +101,18 @@ drop table t1; ...@@ -101,6 +101,18 @@ drop table t1;
--error 1290 --error 1290
insert into t1 values(1); insert into t1 values(1);
#
# BUG #22077 "DROP TEMPORARY TABLE fails with wrong error if read_only is set"
#
# check if DROP TEMPORARY on a non-existing temporary table returns the right
# error
--error ER_BAD_TABLE_ERROR
drop temporary table ttt;
# check if DROP TEMPORARY TABLE IF EXISTS produces a warning with read_only set
drop temporary table if exists ttt;
connection default; connection default;
drop table t1,t2; drop table t1,t2;
drop user test@localhost; drop user test@localhost;
......
...@@ -2519,6 +2519,7 @@ mysql_execute_command(THD *thd) ...@@ -2519,6 +2519,7 @@ mysql_execute_command(THD *thd)
uc_update_queries[lex->sql_command] && uc_update_queries[lex->sql_command] &&
!((lex->sql_command == SQLCOM_CREATE_TABLE) && !((lex->sql_command == SQLCOM_CREATE_TABLE) &&
(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE)) && (lex->create_info.options & HA_LEX_CREATE_TMP_TABLE)) &&
!((lex->sql_command == SQLCOM_DROP_TABLE) && lex->drop_temporary) &&
((lex->sql_command != SQLCOM_UPDATE_MULTI) && ((lex->sql_command != SQLCOM_UPDATE_MULTI) &&
some_non_temp_table_to_be_updated(thd, all_tables))) some_non_temp_table_to_be_updated(thd, all_tables)))
{ {
......
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