mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-5602: CREATE OR REPLACE obtains stricter locks than the connection had before
mysql-test/r/create_or_replace.result: Added test case mysql-test/t/create_or_replace.test: Added test case sql/sql_base.cc: Downgrade locks in LOCK TABLES + CREATE TABLE OR REPLACE sql/sql_table.cc: Downgrade locks in LOCK TABLES + CREATE TABLE OR REPLACE
This commit is contained in:
@ -4882,6 +4882,11 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table,
|
||||
thd->locked_tables_list.add_back_last_deleted_lock(pos_in_locked_tables);
|
||||
if (thd->locked_tables_list.reopen_tables(thd))
|
||||
thd->locked_tables_list.unlink_all_closed_tables(thd, NULL, 0);
|
||||
else
|
||||
{
|
||||
TABLE *table= pos_in_locked_tables->table;
|
||||
table->mdl_ticket->downgrade_lock(MDL_SHARED_NO_READ_WRITE);
|
||||
}
|
||||
}
|
||||
|
||||
err:
|
||||
@ -5195,17 +5200,20 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
|
||||
don't reopen the table when doing statment logging below.
|
||||
*/
|
||||
table->table= pos_in_locked_tables->table;
|
||||
table->table->mdl_ticket->downgrade_lock(MDL_SHARED_NO_READ_WRITE);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Ensure that we have an exclusive lock on target table if we are creating
|
||||
non-temporary table.
|
||||
*/
|
||||
DBUG_ASSERT((create_info->tmp_table()) ||
|
||||
thd->mdl_context.is_lock_owner(MDL_key::TABLE, table->db,
|
||||
table->table_name,
|
||||
MDL_EXCLUSIVE));
|
||||
else
|
||||
{
|
||||
/*
|
||||
Ensure that we have an exclusive lock on target table if we are creating
|
||||
non-temporary table.
|
||||
*/
|
||||
DBUG_ASSERT((create_info->tmp_table()) ||
|
||||
thd->mdl_context.is_lock_owner(MDL_key::TABLE, table->db,
|
||||
table->table_name,
|
||||
MDL_EXCLUSIVE));
|
||||
}
|
||||
|
||||
DEBUG_SYNC(thd, "create_table_like_before_binlog");
|
||||
|
||||
|
Reference in New Issue
Block a user