diff --git a/mysql-test/r/delayed.result b/mysql-test/r/delayed.result index 4d5d656f3ce..da6f36120aa 100644 --- a/mysql-test/r/delayed.result +++ b/mysql-test/r/delayed.result @@ -311,3 +311,25 @@ a b drop table t1; set global low_priority_updates = @old_delayed_updates; End of 5.1 tests +# +# Bug #47274 assert in open_table on CREATE TABLE +# +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +CREATE TABLE t1 ( f1 INTEGER AUTO_INCREMENT, PRIMARY KEY (f1)); +# The following CREATE TABLEs before gave an assert. +INSERT DELAYED t1 VALUES (4); +CREATE TABLE t1 AS SELECT 1 AS f1; +ERROR 42S01: Table 't1' already exists +REPLACE DELAYED t1 VALUES (5); +CREATE TABLE t1 AS SELECT 1 AS f1; +ERROR 42S01: Table 't1' already exists +INSERT DELAYED t1 VALUES (6); +CREATE TABLE t1 (f1 INTEGER); +ERROR 42S01: Table 't1' already exists +CREATE TABLE t2 (f1 INTEGER); +INSERT DELAYED t1 VALUES (7); +CREATE TABLE t1 LIKE t2; +ERROR 42S01: Table 't1' already exists +DROP TABLE t2; +DROP TABLE t1; diff --git a/mysql-test/t/delayed.test b/mysql-test/t/delayed.test index 94ad22b80d0..038b0047497 100644 --- a/mysql-test/t/delayed.test +++ b/mysql-test/t/delayed.test @@ -329,3 +329,38 @@ drop table t1; set global low_priority_updates = @old_delayed_updates; --echo End of 5.1 tests + + + +--echo # +--echo # Bug #47274 assert in open_table on CREATE TABLE +--echo # + +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +--enable_warnings + +CREATE TABLE t1 ( f1 INTEGER AUTO_INCREMENT, PRIMARY KEY (f1)); + +--echo # The following CREATE TABLEs before gave an assert. + +INSERT DELAYED t1 VALUES (4); +--error ER_TABLE_EXISTS_ERROR +CREATE TABLE t1 AS SELECT 1 AS f1; + +REPLACE DELAYED t1 VALUES (5); +--error ER_TABLE_EXISTS_ERROR +CREATE TABLE t1 AS SELECT 1 AS f1; + +INSERT DELAYED t1 VALUES (6); +--error ER_TABLE_EXISTS_ERROR +CREATE TABLE t1 (f1 INTEGER); + +CREATE TABLE t2 (f1 INTEGER); +INSERT DELAYED t1 VALUES (7); +--error ER_TABLE_EXISTS_ERROR +CREATE TABLE t1 LIKE t2; + +DROP TABLE t2; +DROP TABLE t1; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 1ef4d5827ec..fd19a025429 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -2729,6 +2729,12 @@ bool Delayed_insert::handle_inserts(void) thread_safe_increment(delayed_insert_writes,&LOCK_delayed_status); pthread_mutex_lock(&mutex); + /* + Reset the table->auto_increment_field_not_null as it is valid for + only one row. + */ + table->auto_increment_field_not_null= FALSE; + delete row; /* Let READ clients do something once in a while