Skip to content

Commit

Permalink
MDEV-11071 - Assertion `thd->transaction.stmt.is_empty()' failed in
Browse files Browse the repository at this point in the history
             Locked_tables_list::unlock_locked_tables

Similarly to regular DROP TABLE, don't leave locked tables mode if CREATE OR
REPLACE dropped temporary table but failed to cerate new one.

The problem is that there's no track of which temporary table was "locked" by
LOCK TABLES.
  • Loading branch information
svoj committed Dec 29, 2017
1 parent 24774fb commit f5c4795
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
20 changes: 20 additions & 0 deletions mysql-test/r/create_or_replace.result
Original file line number Diff line number Diff line change
Expand Up @@ -458,3 +458,23 @@ CREATE OR REPLACE TABLE t1 AS SELECT f1();
UNLOCK TABLES;
DROP FUNCTION f1;
DROP TABLE t1;
#
# MDEV-11071 - Assertion `thd->transaction.stmt.is_empty()' failed in
# Locked_tables_list::unlock_locked_tables
#
CREATE TEMPORARY TABLE t1(a INT) ENGINE=InnoDB;
CREATE TEMPORARY TABLE t2(a INT);
CREATE TABLE t3(a INT);
LOCK TABLE t2 WRITE;
SELECT * FROM t2;
a
CREATE OR REPLACE TEMPORARY TABLE t1(a INT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
ERROR HY000: CREATE TEMPORARY TABLE is not allowed with ROW_FORMAT=COMPRESSED or KEY_BLOCK_SIZE.
SELECT * FROM t3;
ERROR HY000: Table 't3' was not locked with LOCK TABLES
CREATE OR REPLACE TEMPORARY TABLE t2(a INT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
ERROR HY000: CREATE TEMPORARY TABLE is not allowed with ROW_FORMAT=COMPRESSED or KEY_BLOCK_SIZE.
SELECT * FROM t3;
ERROR HY000: Table 't3' was not locked with LOCK TABLES
UNLOCK TABLES;
DROP TABLE t3;
24 changes: 24 additions & 0 deletions mysql-test/t/create_or_replace.test
Original file line number Diff line number Diff line change
Expand Up @@ -396,3 +396,27 @@ CREATE OR REPLACE TABLE t1 AS SELECT f1();
UNLOCK TABLES;
DROP FUNCTION f1;
DROP TABLE t1;

--echo #
--echo # MDEV-11071 - Assertion `thd->transaction.stmt.is_empty()' failed in
--echo # Locked_tables_list::unlock_locked_tables
--echo #
CREATE TEMPORARY TABLE t1(a INT) ENGINE=InnoDB;
CREATE TEMPORARY TABLE t2(a INT);
CREATE TABLE t3(a INT);
LOCK TABLE t2 WRITE;
SELECT * FROM t2;
# drops t2
--error ER_UNSUPPORT_COMPRESSED_TEMPORARY_TABLE
CREATE OR REPLACE TEMPORARY TABLE t1(a INT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
# make sure we didn't leave locked tables mode
--error ER_TABLE_NOT_LOCKED
SELECT * FROM t3;
# drops t1
--error ER_UNSUPPORT_COMPRESSED_TEMPORARY_TABLE
CREATE OR REPLACE TEMPORARY TABLE t2(a INT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
# make sure we didn't leave locked tables mode
--error ER_TABLE_NOT_LOCKED
SELECT * FROM t3;
UNLOCK TABLES;
DROP TABLE t3;
2 changes: 1 addition & 1 deletion sql/sql_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5111,7 +5111,7 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table,
/* Write log if no error or if we already deleted a table */
if (!result || thd->log_current_statement)
{
if (result && create_info->table_was_deleted)
if (result && create_info->table_was_deleted && pos_in_locked_tables)
{
/*
Possible locked table was dropped. We should remove meta data locks
Expand Down

0 comments on commit f5c4795

Please sign in to comment.