mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-14056 DROP TEMPORARY TABLE IF EXISTS causes error 1290 with read_only option
if it's a DROP TABLE, we cannot detect whether a table is temporary by looking in thd->temporary_tables - because the table might simply not exist at all.
This commit is contained in:
@ -47,6 +47,9 @@ 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 MariaDB server is running with the --read-only option so it cannot execute this statement
|
ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
|
||||||
|
drop temporary table if exists t1;
|
||||||
|
Warnings:
|
||||||
|
Note 1051 Unknown table 't1'
|
||||||
connection default;
|
connection default;
|
||||||
set global read_only=0;
|
set global read_only=0;
|
||||||
lock table t1 write;
|
lock table t1 write;
|
||||||
|
@ -114,6 +114,11 @@ drop table t1;
|
|||||||
--error ER_OPTION_PREVENTS_STATEMENT
|
--error ER_OPTION_PREVENTS_STATEMENT
|
||||||
insert into t1 values(1);
|
insert into t1 values(1);
|
||||||
|
|
||||||
|
#
|
||||||
|
# MDEV-14056 DROP TEMPORARY TABLE IF EXISTS causes error 1290 with read_only option
|
||||||
|
#
|
||||||
|
drop temporary table if exists t1;
|
||||||
|
|
||||||
#
|
#
|
||||||
# Bug#11733 COMMITs should not happen if read-only is set
|
# Bug#11733 COMMITs should not happen if read-only is set
|
||||||
#
|
#
|
||||||
|
@ -811,8 +811,7 @@ out:
|
|||||||
@retval FALSE The statement isn't updating any relevant tables.
|
@retval FALSE The statement isn't updating any relevant tables.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static my_bool deny_updates_if_read_only_option(THD *thd,
|
static bool deny_updates_if_read_only_option(THD *thd, TABLE_LIST *all_tables)
|
||||||
TABLE_LIST *all_tables)
|
|
||||||
{
|
{
|
||||||
DBUG_ENTER("deny_updates_if_read_only_option");
|
DBUG_ENTER("deny_updates_if_read_only_option");
|
||||||
|
|
||||||
@ -821,11 +820,7 @@ static my_bool deny_updates_if_read_only_option(THD *thd,
|
|||||||
|
|
||||||
LEX *lex= thd->lex;
|
LEX *lex= thd->lex;
|
||||||
|
|
||||||
const my_bool user_is_super=
|
if (thd->security_ctx->master_access & SUPER_ACL)
|
||||||
((ulong)(thd->security_ctx->master_access & SUPER_ACL) ==
|
|
||||||
(ulong)SUPER_ACL);
|
|
||||||
|
|
||||||
if (user_is_super)
|
|
||||||
DBUG_RETURN(FALSE);
|
DBUG_RETURN(FALSE);
|
||||||
|
|
||||||
if (!(sql_command_flags[lex->sql_command] & CF_CHANGES_DATA))
|
if (!(sql_command_flags[lex->sql_command] & CF_CHANGES_DATA))
|
||||||
@ -835,30 +830,26 @@ static my_bool deny_updates_if_read_only_option(THD *thd,
|
|||||||
if (lex->sql_command == SQLCOM_UPDATE_MULTI)
|
if (lex->sql_command == SQLCOM_UPDATE_MULTI)
|
||||||
DBUG_RETURN(FALSE);
|
DBUG_RETURN(FALSE);
|
||||||
|
|
||||||
|
if (lex->sql_command == SQLCOM_CREATE_DB ||
|
||||||
|
lex->sql_command == SQLCOM_DROP_DB)
|
||||||
|
DBUG_RETURN(TRUE);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
a table-to-be-created is not in the temp table list yet,
|
a table-to-be-created is not in the temp table list yet,
|
||||||
so CREATE TABLE needs a special treatment
|
so CREATE TABLE needs a special treatment
|
||||||
*/
|
*/
|
||||||
const bool update_real_tables=
|
if (lex->sql_command == SQLCOM_CREATE_TABLE)
|
||||||
lex->sql_command == SQLCOM_CREATE_TABLE
|
DBUG_RETURN(!(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE));
|
||||||
? !(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE)
|
|
||||||
: some_non_temp_table_to_be_updated(thd, all_tables);
|
|
||||||
|
|
||||||
const bool create_or_drop_databases=
|
/*
|
||||||
(lex->sql_command == SQLCOM_CREATE_DB) ||
|
a table-to-be-dropped might not exist (DROP TEMPORARY TABLE IF EXISTS),
|
||||||
(lex->sql_command == SQLCOM_DROP_DB);
|
cannot use the temp table list either.
|
||||||
|
*/
|
||||||
|
if (lex->sql_command == SQLCOM_DROP_TABLE && lex->drop_temporary)
|
||||||
|
DBUG_RETURN(FALSE);
|
||||||
|
|
||||||
if (update_real_tables || create_or_drop_databases)
|
/* Now, check thd->temporary_tables list */
|
||||||
{
|
DBUG_RETURN(some_non_temp_table_to_be_updated(thd, all_tables));
|
||||||
/*
|
|
||||||
An attempt was made to modify one or more non-temporary tables.
|
|
||||||
*/
|
|
||||||
DBUG_RETURN(TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Assuming that only temporary tables are modified. */
|
|
||||||
DBUG_RETURN(FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user