summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/suite/innodb/r/innodb-lock.result21
-rw-r--r--mysql-test/suite/innodb/t/innodb-lock.test26
-rw-r--r--sql/sql_base.cc4
3 files changed, 47 insertions, 4 deletions
diff --git a/mysql-test/suite/innodb/r/innodb-lock.result b/mysql-test/suite/innodb/r/innodb-lock.result
index 1fe0d263fef..260880a1198 100644
--- a/mysql-test/suite/innodb/r/innodb-lock.result
+++ b/mysql-test/suite/innodb/r/innodb-lock.result
@@ -159,3 +159,24 @@ connection con1;
disconnect con1;
connection default;
DROP TABLE t1, t2, t3;
+#
+# MDEV-17749 - Assertion `thd->transaction.stmt.is_empty()' failed in
+# Locked_tables_list::unlock_locked_tables upon ALTER killed
+# under lock
+#
+CREATE TEMPORARY TABLE t1(c INT) ENGINE=InnoDB;
+LOCK TABLES t1 WRITE;
+ALTER TABLE t1 ADD COLUMN c2 INT;
+REPAIR TABLE t1 USE_FRM;
+Table Op Msg_type Msg_text
+t1 repair error Cannot repair temporary table from .frm file
+UNLOCK TABLES;
+DROP TABLE t1;
+CREATE TABLE t1(a INT) ENGINE=InnoDB;
+connect con1, localhost, root;
+LOCK TABLE t1 WRITE;
+ALTER TABLE t1 ADD COLUMN b INT;
+connection default;
+KILL conid;
+disconnect con1;
+DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/t/innodb-lock.test b/mysql-test/suite/innodb/t/innodb-lock.test
index 9e5505270be..e4209fe9f7b 100644
--- a/mysql-test/suite/innodb/t/innodb-lock.test
+++ b/mysql-test/suite/innodb/t/innodb-lock.test
@@ -219,3 +219,29 @@ reap;
disconnect con1;
connection default;
DROP TABLE t1, t2, t3;
+
+
+--echo #
+--echo # MDEV-17749 - Assertion `thd->transaction.stmt.is_empty()' failed in
+--echo # Locked_tables_list::unlock_locked_tables upon ALTER killed
+--echo # under lock
+--echo #
+CREATE TEMPORARY TABLE t1(c INT) ENGINE=InnoDB;
+LOCK TABLES t1 WRITE;
+ALTER TABLE t1 ADD COLUMN c2 INT;
+REPAIR TABLE t1 USE_FRM;
+UNLOCK TABLES;
+DROP TABLE t1;
+
+CREATE TABLE t1(a INT) ENGINE=InnoDB;
+
+connect con1, localhost, root;
+LOCK TABLE t1 WRITE;
+let $conid= `SELECT CONNECTION_ID()`;
+send ALTER TABLE t1 ADD COLUMN b INT;
+
+connection default;
+replace_result $conid conid;
+eval KILL $conid;
+disconnect con1;
+DROP TABLE t1;
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 678790e8bca..e0a6949fad6 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -2391,10 +2391,6 @@ unlink_all_closed_tables(THD *thd, MYSQL_LOCK *lock, size_t reopen_count)
m_locked_tables_count--;
}
}
-
- /* If no tables left, do an automatic UNLOCK TABLES */
- if (thd->lock && thd->lock->table_count == 0)
- unlock_locked_tables(thd);
}