From: Date: August 26 2008 1:46pm Subject: bzr commit into mysql-5.1 branch (ramil:2721) Bug#38821 List-Archive: http://lists.mysql.com/commits/52548 X-Bug: 38821 Message-Id: <200808261146.m7QBkNRi029289@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit #At file:///home/ram/mysql/b38821.5.1/ 2721 Ramil Kalimullin 2008-08-26 Fix for bug#38821: Assert table->auto_increment_field_not_null failed in open_table() Problem: repeating "CREATE... ( AUTOINCREMENT) ... SELECT" may lead to an assertion failure. Fix: reset table->auto_increment_field_not_null after each record writing. modified: mysql-test/r/create.result mysql-test/t/create.test sql/sql_insert.cc per-file messages: mysql-test/r/create.result Fix for bug#38821: Assert table->auto_increment_field_not_null failed in open_table() - test result. mysql-test/t/create.test Fix for bug#38821: Assert table->auto_increment_field_not_null failed in open_table() - test case. sql/sql_insert.cc Fix for bug#38821: Assert table->auto_increment_field_not_null failed in open_table() - reset table->auto_increment_field_not_null after writing a record for "{CREATE, INSERT}..SELECT". === modified file 'mysql-test/r/create.result' --- a/mysql-test/r/create.result 2008-05-13 12:06:32 +0000 +++ b/mysql-test/r/create.result 2008-08-26 11:46:19 +0000 @@ -1877,5 +1877,16 @@ c1 c2 DROP TABLE t1; # -- End of Bug#34274 +CREATE TABLE t1 (a INTEGER AUTO_INCREMENT PRIMARY KEY, b INTEGER NOT NULL); +INSERT IGNORE INTO t1 (b) VALUES (5); +CREATE TABLE IF NOT EXISTS t2 (a INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY) +SELECT a FROM t1; +CREATE TABLE IF NOT EXISTS t2 (a INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY) +SELECT a FROM t1; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +CREATE TABLE IF NOT EXISTS t2 (a INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY) +SELECT a FROM t1; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +DROP TABLE t1, t2; End of 5.1 tests === modified file 'mysql-test/t/create.test' --- a/mysql-test/t/create.test 2008-05-13 12:06:32 +0000 +++ b/mysql-test/t/create.test 2008-08-26 11:46:19 +0000 @@ -1509,5 +1509,23 @@ DROP TABLE t1; ########################################################################### +# +# Bug#38821: Assert table->auto_increment_field_not_null failed in open_table() +# +CREATE TABLE t1 (a INTEGER AUTO_INCREMENT PRIMARY KEY, b INTEGER NOT NULL); +INSERT IGNORE INTO t1 (b) VALUES (5); + +CREATE TABLE IF NOT EXISTS t2 (a INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY) + SELECT a FROM t1; +--error 1062 +CREATE TABLE IF NOT EXISTS t2 (a INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY) + SELECT a FROM t1; +--error 1062 +CREATE TABLE IF NOT EXISTS t2 (a INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY) + SELECT a FROM t1; + +DROP TABLE t1, t2; + + --echo --echo End of 5.1 tests === modified file 'sql/sql_insert.cc' --- a/sql/sql_insert.cc 2008-07-11 18:51:10 +0000 +++ b/sql/sql_insert.cc 2008-08-26 11:46:19 +0000 @@ -3067,6 +3067,7 @@ bool select_insert::send_data(List } error= write_record(thd, table, &info); + table->auto_increment_field_not_null= FALSE; if (!error) {