List:Commits« Previous MessageNext Message »
From:Jon Olav Hauglid Date:January 19 2011 12:10pm
Subject:bzr commit into mysql-trunk branch (jon.hauglid:3532) Bug#58709
View as plain text  
#At file:///export/home/x/mysql-trunk-bug58709/ based on revid:anders.song@stripped

 3532 Jon Olav Hauglid	2011-01-19
      Bug #58709 assert in mysql_execute_command
      
      The triggered assert checks that either an error has been reported or
      the statement has been killed if execution of a stored routine fails.
      It was triggered if a stored routine had a DELETE IGNORE statement
      which failed but due to IGNORE had not reported any error.
      
      This patch fixes the problem by changing mysql_delete() to return
      a value indicating failure only if an error has been reported or
      the statement has been killed.
      
      Test case added to delete.test.

    modified:
      mysql-test/r/delete.result
      mysql-test/t/delete.test
      sql/sql_delete.cc
=== modified file 'mysql-test/r/delete.result'
--- a/mysql-test/r/delete.result	2010-10-04 08:25:04 +0000
+++ b/mysql-test/r/delete.result	2011-01-19 12:10:22 +0000
@@ -524,3 +524,26 @@ DELETE v2 FROM v2;
 ERROR HY000: Can not delete from join view 'test.v2'
 DROP VIEW v2, v1;
 DROP TABLE t1, t2;
+#
+# Bug#58709 assert in mysql_execute_command
+#
+DROP TABLE IF EXISTS t2, t1;
+DROP PROCEDURE IF EXISTS p1;
+CREATE TABLE t1 (i INT PRIMARY KEY) engine=InnoDB;
+CREATE TABLE t2 (i INT, FOREIGN KEY (i) REFERENCES t1 (i) ON DELETE NO ACTION) engine=InnoDB;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (1);
+DELETE IGNORE FROM t1 WHERE i = 1;
+Warnings:
+Error	1451	Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`i`) REFERENCES `t1` (`i`) ON DELETE NO ACTION)
+CREATE PROCEDURE p1() DELETE IGNORE FROM t1 WHERE i = 1;
+CALL p1();
+Warnings:
+Error	1451	Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`i`) REFERENCES `t1` (`i`) ON DELETE NO ACTION)
+PREPARE stm FROM 'CALL p1()';
+EXECUTE stm;
+Warnings:
+Error	1451	Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`i`) REFERENCES `t1` (`i`) ON DELETE NO ACTION)
+DEALLOCATE PREPARE stm;
+DROP TABLE t2, t1;
+DROP PROCEDURE p1;

=== modified file 'mysql-test/t/delete.test'
--- a/mysql-test/t/delete.test	2010-10-04 08:25:04 +0000
+++ b/mysql-test/t/delete.test	2011-01-19 12:10:22 +0000
@@ -580,3 +580,33 @@ DELETE v2 FROM v2;
 
 DROP VIEW v2, v1;
 DROP TABLE t1, t2;
+
+
+--echo #
+--echo # Bug#58709 assert in mysql_execute_command
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t2, t1;
+DROP PROCEDURE IF EXISTS p1;
+--enable_warnings
+
+CREATE TABLE t1 (i INT PRIMARY KEY) engine=InnoDB;
+CREATE TABLE t2 (i INT, FOREIGN KEY (i) REFERENCES t1 (i) ON DELETE NO ACTION) engine=InnoDB;
+
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (1);
+
+DELETE IGNORE FROM t1 WHERE i = 1;
+
+CREATE PROCEDURE p1() DELETE IGNORE FROM t1 WHERE i = 1;
+# This triggered the assert
+CALL p1();
+
+PREPARE stm FROM 'CALL p1()';
+# This also triggered the assert
+EXECUTE stm;
+DEALLOCATE PREPARE stm;
+
+DROP TABLE t2, t1;
+DROP PROCEDURE p1;

=== modified file 'sql/sql_delete.cc'
--- a/sql/sql_delete.cc	2010-12-17 09:41:21 +0000
+++ b/sql/sql_delete.cc	2011-01-19 12:10:22 +0000
@@ -413,7 +413,7 @@ cleanup:
     my_ok(thd, deleted);
     DBUG_PRINT("info",("%ld records deleted",(long) deleted));
   }
-  DBUG_RETURN(error >= 0 || thd->is_error());
+  DBUG_RETURN(thd->killed || thd->is_error());
 }
 
 


Attachment: [text/bzr-bundle] bzr/jon.hauglid@oracle.com-20110119121022-0eykn27v3ro8fb3n.bundle
Thread
bzr commit into mysql-trunk branch (jon.hauglid:3532) Bug#58709Jon Olav Hauglid19 Jan