mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-19198 - DBUG assert in CREATE IF NOT EXIST under LOCK TABLES WRITE
Relax the assert condition. A locked table that did existed prior to CREATE IF NOT EXIST, retains the MDL_NO_SHARED_READ_WRITE MDL lock prio.
This commit is contained in:
15
mysql-test/r/mdev19198.result
Normal file
15
mysql-test/r/mdev19198.result
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
CREATE TABLE t1 (c INT);
|
||||||
|
CREATE TABLE t2 (c INT);
|
||||||
|
LOCK TABLES t1 WRITE, t2 READ;
|
||||||
|
CREATE TABLE IF NOT EXISTS t1 LIKE t2;
|
||||||
|
Warnings:
|
||||||
|
Note 1050 Table 't1' already exists
|
||||||
|
UNLOCK TABLES;
|
||||||
|
LOCK TABLES t1 READ , t2 READ;
|
||||||
|
CREATE TABLE IF NOT EXISTS t1 LIKE t2;
|
||||||
|
ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
|
||||||
|
UNLOCK TABLES;
|
||||||
|
CREATE TABLE IF NOT EXISTS t1 LIKE t2;
|
||||||
|
Warnings:
|
||||||
|
Note 1050 Table 't1' already exists
|
||||||
|
DROP TABLES t1,t2;
|
15
mysql-test/t/mdev19198.test
Normal file
15
mysql-test/t/mdev19198.test
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
CREATE TABLE t1 (c INT);
|
||||||
|
CREATE TABLE t2 (c INT);
|
||||||
|
|
||||||
|
LOCK TABLES t1 WRITE, t2 READ;
|
||||||
|
CREATE TABLE IF NOT EXISTS t1 LIKE t2;
|
||||||
|
UNLOCK TABLES;
|
||||||
|
|
||||||
|
LOCK TABLES t1 READ , t2 READ;
|
||||||
|
--error ER_TABLE_NOT_LOCKED_FOR_WRITE
|
||||||
|
CREATE TABLE IF NOT EXISTS t1 LIKE t2;
|
||||||
|
UNLOCK TABLES;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS t1 LIKE t2;
|
||||||
|
|
||||||
|
DROP TABLES t1,t2;
|
@ -5615,11 +5615,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
|
Ensure that we have an exclusive lock on target table if we are creating
|
||||||
non-temporary table.
|
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()) ||
|
DBUG_ASSERT((create_info->tmp_table()) ||
|
||||||
thd->mdl_context.is_lock_owner(MDL_key::TABLE, table->db,
|
thd->mdl_context.is_lock_owner(MDL_key::TABLE, table->db,
|
||||||
table->table_name,
|
table->table_name,
|
||||||
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");
|
DEBUG_SYNC(thd, "create_table_like_before_binlog");
|
||||||
|
Reference in New Issue
Block a user