summaryrefslogtreecommitdiff
path: root/sql/sql_parse.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2017-10-22 13:03:41 +0200
committerSergei Golubchik <serg@mariadb.org>2017-10-22 13:03:41 +0200
commit9d2e2d753323a934604d25144b9d1ecaf34b47d8 (patch)
tree051a721f7ea77c2278d09323e36088abe22aa66a /sql/sql_parse.cc
parentd11af09865299033d5eef64531704f6ab8af5304 (diff)
parent2eb3c5e5420a724945a4cba914df25aa1e3744ce (diff)
downloadmariadb-git-9d2e2d753323a934604d25144b9d1ecaf34b47d8.tar.gz
Merge branch '10.0' into 10.1
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r--sql/sql_parse.cc45
1 files changed, 19 insertions, 26 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 6f9e4677c0b..e14531a40f0 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1160,8 +1160,7 @@ out:
@retval FALSE The statement isn't updating any relevant tables.
*/
-static my_bool deny_updates_if_read_only_option(THD *thd,
- TABLE_LIST *all_tables)
+static bool deny_updates_if_read_only_option(THD *thd, TABLE_LIST *all_tables)
{
DBUG_ENTER("deny_updates_if_read_only_option");
@@ -1170,11 +1169,7 @@ static my_bool deny_updates_if_read_only_option(THD *thd,
LEX *lex= thd->lex;
- const my_bool user_is_super=
- ((ulong)(thd->security_ctx->master_access & SUPER_ACL) ==
- (ulong)SUPER_ACL);
-
- if (user_is_super)
+ if (thd->security_ctx->master_access & SUPER_ACL)
DBUG_RETURN(FALSE);
if (!(sql_command_flags[lex->sql_command] & CF_CHANGES_DATA))
@@ -1184,28 +1179,26 @@ static my_bool deny_updates_if_read_only_option(THD *thd,
if (lex->sql_command == SQLCOM_UPDATE_MULTI)
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,
so CREATE TABLE needs a special treatment
*/
- const bool update_real_tables= lex->sql_command == SQLCOM_CREATE_TABLE ?
- !lex->tmp_table() : some_non_temp_table_to_be_updated(thd, all_tables);
-
- const bool create_or_drop_databases=
- (lex->sql_command == SQLCOM_CREATE_DB) ||
- (lex->sql_command == SQLCOM_DROP_DB);
-
- if (update_real_tables || create_or_drop_databases)
- {
- /*
- An attempt was made to modify one or more non-temporary tables.
- */
- DBUG_RETURN(TRUE);
- }
+ if (lex->sql_command == SQLCOM_CREATE_TABLE)
+ DBUG_RETURN(!lex->tmp_table());
+ /*
+ a table-to-be-dropped might not exist (DROP TEMPORARY TABLE IF EXISTS),
+ cannot use the temp table list either.
+ */
+ if (lex->sql_command == SQLCOM_DROP_TABLE && lex->tmp_table())
+ DBUG_RETURN(FALSE);
- /* Assuming that only temporary tables are modified. */
- DBUG_RETURN(FALSE);
+ /* Now, check thd->temporary_tables list */
+ DBUG_RETURN(some_non_temp_table_to_be_updated(thd, all_tables));
}
@@ -3310,7 +3303,7 @@ mysql_execute_command(THD *thd)
#ifdef WITH_PARTITION_STORAGE_ENGINE
{
partition_info *part_info= thd->lex->part_info;
- if (part_info && !(part_info= thd->lex->part_info->get_clone(thd)))
+ if (part_info && !(part_info= part_info->get_clone(thd)))
{
res= -1;
goto end_with_restore_list;
@@ -3780,7 +3773,7 @@ end_with_restore_list:
if (up_result != 2)
break;
}
- /* Fall through */
+ /* fall through */
case SQLCOM_UPDATE_MULTI:
{
DBUG_ASSERT(first_table == all_tables && first_table != 0);
@@ -3891,7 +3884,7 @@ end_with_restore_list:
DBUG_PRINT("debug", ("Just after generate_incident()"));
}
#endif
- /* fall through */
+ /* fall through */
case SQLCOM_INSERT:
{
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_INSERT_REPLACE);