#At file:///export/home/x/mysql-5.1-bugteam-test/ based on revid:sergey.glukhov@stripped
3438 Jon Olav Hauglid 2010-06-22
Bug #54117 crash in thr_multi_unlock, temporary table
This crash occured after ALTER TABLE was used on a temporary
transactional table locked by LOCK TABLES. Any later attempts to
execute LOCK/UNLOCK TABLES, caused the server to crash.
The reason for the crash was the list of locked tables would
end up having a pointer to a free'd table instance. This happened
because ALTER TABLE deleted the table without also removing the
table reference from the locked tables list.
This patch fixes the problem by making sure ALTER TABLE also
removes the table from the locked tables list.
Test case added to innodb_mysql.test.
modified:
mysql-test/r/innodb_mysql.result
mysql-test/t/innodb_mysql.test
sql/sql_table.cc
=== modified file 'mysql-test/r/innodb_mysql.result'
--- a/mysql-test/r/innodb_mysql.result 2010-06-21 11:09:58 +0000
+++ b/mysql-test/r/innodb_mysql.result 2010-06-22 13:55:26 +0000
@@ -2455,4 +2455,12 @@ AND f5 = 'abcdefghijklmnopwrst' AND f2 =
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge PRIMARY,idx1,idx2 idx2,idx1,PRIMARY 7,60,4 NULL 1 Using intersect(idx2,idx1,PRIMARY); Using where
DROP TABLE t1;
+#
+# Bug#54117 crash in thr_multi_unlock, temporary table
+#
+CREATE TEMPORARY TABLE t1(a INT) ENGINE = InnoDB;
+LOCK TABLES t1 READ;
+ALTER TABLE t1 COMMENT 'test';
+UNLOCK TABLES;
+DROP TABLE t1;
End of 5.1 tests
=== modified file 'mysql-test/t/innodb_mysql.test'
--- a/mysql-test/t/innodb_mysql.test 2010-06-21 11:09:58 +0000
+++ b/mysql-test/t/innodb_mysql.test 2010-06-22 13:55:26 +0000
@@ -694,4 +694,18 @@ AND f5 = 'abcdefghijklmnopwrst' AND f2 =
DROP TABLE t1;
+
+--echo #
+--echo # Bug#54117 crash in thr_multi_unlock, temporary table
+--echo #
+
+CREATE TEMPORARY TABLE t1(a INT) ENGINE = InnoDB;
+
+LOCK TABLES t1 READ;
+ALTER TABLE t1 COMMENT 'test';
+UNLOCK TABLES;
+
+DROP TABLE t1;
+
+
--echo End of 5.1 tests
=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc 2010-06-10 20:45:22 +0000
+++ b/sql/sql_table.cc 2010-06-22 13:55:26 +0000
@@ -7387,6 +7387,11 @@ view_err:
mysql_unlock_tables(thd, thd->lock);
thd->lock=0;
}
+ /*
+ If LOCK TABLES list is not empty and contains this table,
+ unlock the table and remove the table from this list.
+ */
+ mysql_lock_remove(thd, thd->locked_tables, table, FALSE);
/* Remove link to old table and rename the new one */
close_temporary_table(thd, table, 1, 1);
/* Should pass the 'new_name' as we store table name in the cache */
Attachment: [text/bzr-bundle] bzr/jon.hauglid@sun.com-20100622135526-ylnjmglxlamxyizh.bundle