MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Martin Hansson Date:May 4 2009 12:56pm
Subject:bzr commit into mysql-6.0-bugteam branch (mhansson:3254) Bug#44306
View as plain text  
#At file:///data0/martin/bzr/bug44306/6.0bt/ based on revid:aelkin@stripped

 3254 Martin Hansson	2009-05-04 [merge]
      Bug#44306: Assertion fail on duplicate key error in 
      'INSERT ... SELECT' statements
      
      Merge

    modified:
      mysql-test/r/insert_select.result
      mysql-test/t/insert_select.test
      sql/sql_select.cc
=== modified file 'mysql-test/r/insert_select.result'
--- a/mysql-test/r/insert_select.result	2007-09-24 13:23:40 +0000
+++ b/mysql-test/r/insert_select.result	2009-05-04 12:45:36 +0000
@@ -765,6 +765,11 @@ f1	f2
 2	2
 10	10
 DROP TABLE t1, t2;
+CREATE TABLE t1 ( a INT KEY, b INT );
+INSERT INTO t1 VALUES ( 0, 1 );
+INSERT INTO t1 ( b ) SELECT MAX( b ) FROM t1 WHERE b = 2;
+ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
+DROP TABLE t1;
 SET SQL_MODE='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
 CREATE TABLE t1 (c VARCHAR(30), INDEX ix_c (c(10)));
 CREATE TABLE t2 (d VARCHAR(10));

=== modified file 'mysql-test/t/insert_select.test'
--- a/mysql-test/t/insert_select.test	2007-09-24 13:23:40 +0000
+++ b/mysql-test/t/insert_select.test	2009-05-04 12:45:36 +0000
@@ -324,6 +324,16 @@ SELECT * FROM t2;
 DROP TABLE t1, t2;
 
 #
+# Bug#44306: Assertion fail on duplicate key error in 'INSERT ... SELECT' 
+# statements
+#
+CREATE TABLE t1 ( a INT KEY, b INT );
+INSERT INTO t1 VALUES ( 0, 1 );
+--error ER_DUP_ENTRY
+INSERT INTO t1 ( b ) SELECT MAX( b ) FROM t1 WHERE b = 2;
+DROP TABLE t1;
+
+#
 # Bug #26207: inserts don't work with shortened index
 #
 SET SQL_MODE='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2009-04-30 19:37:21 +0000
+++ b/sql/sql_select.cc	2009-05-04 12:55:57 +0000
@@ -10804,15 +10804,17 @@ return_zero_rows(JOIN *join, select_resu
   if (!(result->send_result_set_metadata(fields,
                               Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)))
   {
+    bool send_error= FALSE;
     if (send_row)
     {
       List_iterator_fast<Item> it(fields);
       Item *item;
       while ((item= it++))
 	item->no_rows_in_result();
-      result->send_data(fields);
+      send_error= result->send_data(fields);
     }
-    result->send_eof();				// Should be safe
+    if (!send_error)
+      result->send_eof();				// Should be safe
   }
   /* Update results for FOUND_ROWS */
   join->thd->limit_found_rows= join->thd->examined_row_count= 0;


Attachment: [text/bzr-bundle] bzr/mhansson@mysql.com-20090504125557-4ckdpd4u3jan0ygi.bundle
Thread
bzr commit into mysql-6.0-bugteam branch (mhansson:3254) Bug#44306Martin Hansson4 May