summaryrefslogtreecommitdiff
path: root/sql/sql_table.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r--sql/sql_table.cc11
1 files changed, 10 insertions, 1 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 4883fd93782..c70639d71db 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -5818,11 +5818,18 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
/*
Ensure that we have an exclusive lock on target table if we are creating
non-temporary table.
+ If we're creating non-temporary table, then either
+ - there is an exclusive lock on the table
+ or
+ - there was CREATE IF EXIST, and the table was not created
+ (it existed), and was previously locked
*/
DBUG_ASSERT((create_info->tmp_table()) ||
thd->mdl_context.is_lock_owner(MDL_key::TABLE, table->db.str,
table->table_name.str,
- MDL_EXCLUSIVE));
+ MDL_EXCLUSIVE) ||
+ (thd->locked_tables_mode && pos_in_locked_tables &&
+ create_info->if_not_exists()));
}
DEBUG_SYNC(thd, "create_table_like_before_binlog");
@@ -7788,6 +7795,8 @@ static bool mysql_inplace_alter_table(THD *thd,
goto rollback;
}
+ DEBUG_SYNC(thd, "alter_table_inplace_after_commit");
+
thd->drop_temporary_table(altered_table, NULL, false);
}