mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-19198 - DBUG assert in CREATE IF NOT EXIST under LOCK TABLES WRITE
Fixed the ASSERT to take care of the case when table already existed.
This commit is contained in:
@ -535,3 +535,25 @@ DROP TABLE t;
|
|||||||
#
|
#
|
||||||
# End of 10.5 tests
|
# End of 10.5 tests
|
||||||
#
|
#
|
||||||
|
#
|
||||||
|
# MDEV-19198 Assertion `(create_info->tmp_table()) || ....`
|
||||||
|
# failed in mysql_create_like_table
|
||||||
|
#
|
||||||
|
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;
|
||||||
|
#
|
||||||
|
# End of 10.6 tests
|
||||||
|
#
|
||||||
|
@ -651,3 +651,28 @@ DROP TABLE t;
|
|||||||
--echo #
|
--echo #
|
||||||
--echo # End of 10.5 tests
|
--echo # End of 10.5 tests
|
||||||
--echo #
|
--echo #
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-19198 Assertion `(create_info->tmp_table()) || ....`
|
||||||
|
--echo # failed in mysql_create_like_table
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # End of 10.6 tests
|
||||||
|
--echo #
|
||||||
|
@ -4504,7 +4504,7 @@ warn:
|
|||||||
in various version of CREATE TABLE statement.
|
in various version of CREATE TABLE statement.
|
||||||
|
|
||||||
@result
|
@result
|
||||||
1 unspefied error
|
1 unspecifed error
|
||||||
2 error; Don't log create statement
|
2 error; Don't log create statement
|
||||||
0 ok
|
0 ok
|
||||||
-1 Table was used with IF NOT EXISTS and table existed (warning, not error)
|
-1 Table was used with IF NOT EXISTS and table existed (warning, not error)
|
||||||
@ -5203,14 +5203,10 @@ 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. We don't have or need the lock if the create failed
|
||||||
If we're creating non-temporary table, then either
|
because of existing table when using "if exists".
|
||||||
- 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()) || create_res < 0 ||
|
||||||
thd->mdl_context.is_lock_owner(MDL_key::TABLE, table->db.str,
|
thd->mdl_context.is_lock_owner(MDL_key::TABLE, table->db.str,
|
||||||
table->table_name.str,
|
table->table_name.str,
|
||||||
MDL_EXCLUSIVE) ||
|
MDL_EXCLUSIVE) ||
|
||||||
|
Reference in New Issue
Block a user