MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Jon Olav Hauglid Date:October 23 2009 1:09pm
Subject:bzr commit into mysql-5.1 branch (jon.hauglid:3180) Bug#47919
View as plain text  
#At file:///export/home/z/mysql-5.1-bug47919/ based on revid:bjorn.munch@stripped

 3180 Jon Olav Hauglid	2009-10-23
      Bug #47919 assert in open_table during ALTER temporary table
      
      This assertion would occur if UPDATE was used to update multiple
      tables containing an AUTO_INCREMENT column and if the inserted
      row had a user-supplied value for that column. The assertion 
      could then be triggered by the next statement.
      
      The problem was only noticeable on debug builds of the server.
      
      The cause of the problem was that the code for multi update did
      not properly reset the TABLE->auto_increment_if_null flag after update.
      The flag is used to indicate that a non-null value of an auto_increment field
      has been provided by the user or retrieved from a current record.
      Open_tables() contains an assertion that tests this flag, and this
      was triggered in this case by ALTER TABLE.
      
      This patch fixes the problem by resetting the auto_increment_if_null
      field to FALSE once a row has been updated.
      
      This bug is similar to Bug#47274, but for multi update rather
      than INSERT DELAYED.
      
      Test case added to update.test.

    modified:
      mysql-test/r/update.result
      mysql-test/t/update.test
      sql/sql_update.cc
=== modified file 'mysql-test/r/update.result'
--- a/mysql-test/r/update.result	2008-11-28 16:36:07 +0000
+++ b/mysql-test/r/update.result	2009-10-23 13:09:14 +0000
@@ -503,3 +503,14 @@ ERROR HY000: Recursive stored functions 
 DROP TABLE t1;
 DROP FUNCTION f1;
 End of 5.0 tests
+#
+# Bug #47919 assert in open_table during ALTER temporary table
+#
+CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT, PRIMARY KEY (f1));
+CREATE TEMPORARY TABLE t2 LIKE t1;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (1);
+ALTER TABLE t2 COMMENT = 'ABC';
+UPDATE t2, t1 SET t2.f1 = 2, t1.f1 = 9;
+ALTER TABLE t2 COMMENT = 'DEF';
+DROP TABLE t1, t2;

=== modified file 'mysql-test/t/update.test'
--- a/mysql-test/t/update.test	2008-11-28 16:36:07 +0000
+++ b/mysql-test/t/update.test	2009-10-23 13:09:14 +0000
@@ -452,3 +452,18 @@ DROP TABLE t1;
 DROP FUNCTION f1;
 
 --echo End of 5.0 tests
+
+--echo #
+--echo # Bug #47919 assert in open_table during ALTER temporary table
+--echo #
+
+CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT, PRIMARY KEY (f1));
+CREATE TEMPORARY TABLE t2 LIKE t1;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (1);
+
+ALTER TABLE t2 COMMENT = 'ABC';
+UPDATE t2, t1 SET t2.f1 = 2, t1.f1 = 9;
+ALTER TABLE t2 COMMENT = 'DEF';
+
+DROP TABLE t1, t2;

=== modified file 'sql/sql_update.cc'
--- a/sql/sql_update.cc	2009-08-28 16:21:54 +0000
+++ b/sql/sql_update.cc	2009-10-23 13:09:14 +0000
@@ -1696,6 +1696,11 @@ bool multi_update::send_data(List<Item> 
                                                TRG_EVENT_UPDATE))
 	DBUG_RETURN(1);
 
+      /*
+        Reset the table->auto_increment_field_not_null as it is valid for
+        only one row.
+      */
+      table->auto_increment_field_not_null= FALSE;
       found++;
       if (!can_compare_record || compare_record(table))
       {


Attachment: [text/bzr-bundle] bzr/jon.hauglid@sun.com-20091023130914-uxko0mfn3bugtlgs.bundle
Thread
bzr commit into mysql-5.1 branch (jon.hauglid:3180) Bug#47919Jon Olav Hauglid23 Oct