List:Commits« Previous MessageNext Message »
From:Jon Olav Hauglid Date:February 2 2011 10:32am
Subject:bzr push into mysql-trunk branch (jon.hauglid:3589 to 3590) Bug#58709
View as plain text  
 3590 Jon Olav Hauglid	2011-02-02
      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
 3589 Tor Didriksen	2011-02-02 [merge]
      Empty merge of Backport of fix for Bug#52123

=== 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-02-02 10:32:21 +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-02-02 10:32:21 +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-02-02 10:32:21 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -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->is_error() || thd->killed);
 }
 
 

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (jon.hauglid:3589 to 3590) Bug#58709Jon Olav Hauglid2 Feb