#At file:///export/home/z/mysql-next-bugfixing-bug47107/ based on revid:jon.hauglid@stripped
2814 Jon Olav Hauglid 2009-09-10
Bug #47107 assert in notify_shared_lock on incorrect CREATE TABLE , HANDLER
The problem here was that the HANDLER was not closed by CREATE TABLE
before CREATE tried to open and lock the table. Acquire exclusive MDL
lock on the table to be created would therefore fail since HANDLER
already had a shared MDL lock. This triggered an assert since the
HANDLER and CREATE statements came from the same thread (self-deadlock).
This patch resolves the issue by closing any open HANDLERs on tables
to be created by CREATE TABLE, similar to what is already done for
DROP and ALTER TABLE.
Test case added to create.test.
modified:
mysql-test/r/create.result
mysql-test/t/create.test
sql/sql_parse.cc
=== modified file 'mysql-test/r/create.result'
--- a/mysql-test/r/create.result 2009-07-29 10:25:07 +0000
+++ b/mysql-test/r/create.result 2009-09-10 09:33:01 +0000
@@ -1948,3 +1948,15 @@ END ;|
ERROR 42000: This version of MySQL doesn't yet support 'multiple triggers with the same action time and event for one table'
DROP TABLE t1;
DROP TABLE B;
+#
+# Bug #47107 assert in notify_shared_lock on incorrect
+# CREATE TABLE , HANDLER
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1(f1 integer);
+HANDLER t1 OPEN AS A;
+# The following CREATE TABLEs before gave an assert.
+CREATE TABLE t1 AS SELECT 1 FROM t1_not_exists;
+ERROR 42S02: Table 'test.t1_not_exists' doesn't exist
+CREATE TABLE t1(f1 integer);
+ERROR 42S01: Table 't1' already exists
+DROP TABLE t1;
=== modified file 'mysql-test/t/create.test'
--- a/mysql-test/t/create.test 2009-07-29 10:25:07 +0000
+++ b/mysql-test/t/create.test 2009-09-10 09:33:01 +0000
@@ -1624,3 +1624,25 @@ END ;|
DROP TABLE t1;
DROP TABLE B;
+
+
+--echo #
+--echo # Bug #47107 assert in notify_shared_lock on incorrect
+--echo # CREATE TABLE , HANDLER
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1(f1 integer);
+HANDLER t1 OPEN AS A;
+
+--echo # The following CREATE TABLEs before gave an assert.
+
+--error ER_NO_SUCH_TABLE
+CREATE TABLE t1 AS SELECT 1 FROM t1_not_exists;
+
+--error ER_TABLE_EXISTS_ERROR
+CREATE TABLE t1(f1 integer);
+
+DROP TABLE t1;
=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc 2009-09-03 09:09:27 +0000
+++ b/sql/sql_parse.cc 2009-09-10 09:33:01 +0000
@@ -2605,6 +2605,11 @@ mysql_execute_command(THD *thd)
create_table->open_strategy= TABLE_LIST::OPEN_IF_EXISTS;
create_table->lock_strategy= TABLE_LIST::EXCLUSIVE_DOWNGRADABLE_MDL;
+ /*
+ Close any open handlers for the table
+ */
+ mysql_ha_rm_tables(thd, create_table);
+
if (select_lex->item_list.elements) // With select
{
select_result *result;
Attachment: [text/bzr-bundle] bzr/jon.hauglid@sun.com-20090910093301-5l55i4sc6zxqn6qk.bundle