diff options
author | Vladislav Vaintroub <wlad@mariadb.com> | 2021-04-28 00:36:19 +0200 |
---|---|---|
committer | Vladislav Vaintroub <wlad@mariadb.com> | 2021-04-28 08:53:37 +0200 |
commit | b9fbd102dd294eb8247eb22d92c68e933fac4595 (patch) | |
tree | 1d9016c5e891b6ee04e0327df87c7b428415c0a2 /sql/sql_table.cc | |
parent | a6e97dad8a333e22d6d757df3afbd348be74347c (diff) | |
download | mariadb-git-b9fbd102dd294eb8247eb22d92c68e933fac4595.tar.gz |
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.
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r-- | sql/sql_table.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 2b26af6e9ba..3a3a903bc35 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -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 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, 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"); |