MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Magne Mahre Date:September 20 2009 2:43pm
Subject:bzr commit into mysql-6.0-bugfixing branch (magne.mahre:2826) Bug#46374
View as plain text  
#At file:///data/z/mysql-6.0-codebase-bugfixing-46374/ based on revid:alik@stripped

 2826 Magne Mahre	2009-09-20
      Bug #46374 crash, INSERT INTO t1 uses function, function modifies t1
                  
      An error occuring in the execution of a stored procedure, called
      from do_select is masked, since the error condition is not
      propagated back to the caller (join->conds->val_int() returns
      a result value, and not an error code)
                  
      An explicit check was added to see if the thd error code has been
      set, and if so, the loop status is set to the error state.

    modified:
      mysql-test/r/sp-error.result
      mysql-test/t/sp-error.test
      sql/sql_select.cc
=== modified file 'mysql-test/r/sp-error.result'
--- a/mysql-test/r/sp-error.result	2009-09-16 05:54:22 +0000
+++ b/mysql-test/r/sp-error.result	2009-09-20 14:42:51 +0000
@@ -1690,3 +1690,14 @@ NULL
 SELECT non_existent (a) FROM t1 WHERE b = 999999;
 ERROR 42000: FUNCTION test.non_existent does not exist
 DROP TABLE t1;
+CREATE TABLE t1 ( f2 INTEGER, f3 INTEGER );
+INSERT INTO t1 VALUES  ( 1, 1 );
+CREATE FUNCTION func_1 () RETURNS INTEGER
+BEGIN
+INSERT INTO t1 SELECT * FROM t1 ;
+RETURN 1 ;
+END|
+INSERT INTO t1 SELECT * FROM (SELECT 2 AS f1, 2 AS f2) AS A WHERE func_1() = 5;
+ERROR HY000: Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
+DROP FUNCTION func_1;
+DROP TABLE t1;

=== modified file 'mysql-test/t/sp-error.test'
--- a/mysql-test/t/sp-error.test	2009-05-29 08:09:00 +0000
+++ b/mysql-test/t/sp-error.test	2009-09-20 14:42:51 +0000
@@ -2517,3 +2517,33 @@ SELECT AVG (a) FROM t1 WHERE b = 999999;
 --error ER_SP_DOES_NOT_EXIST
 SELECT non_existent (a) FROM t1 WHERE b = 999999;
 DROP TABLE t1;
+
+
+
+#
+# Bug #46374 crash, INSERT INTO t1 uses function, function modifies t1
+#
+CREATE TABLE t1 ( f2 INTEGER, f3 INTEGER );
+INSERT INTO t1 VALUES  ( 1, 1 );
+
+delimiter |;
+
+CREATE FUNCTION func_1 () RETURNS INTEGER
+BEGIN
+  INSERT INTO t1 SELECT * FROM t1 ;
+  RETURN 1 ;
+END|
+
+delimiter ;|
+
+# The bug caused the following INSERT statement to trigger
+# an assertion.   Error 1442 is the correct response
+#
+--error 1442
+INSERT INTO t1 SELECT * FROM (SELECT 2 AS f1, 2 AS f2) AS A WHERE func_1() = 5;
+
+# Cleanup
+DROP FUNCTION func_1;
+DROP TABLE t1;
+
+

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2009-09-18 06:22:43 +0000
+++ b/sql/sql_select.cc	2009-09-20 14:42:51 +0000
@@ -15788,6 +15788,13 @@ do_select(JOIN *join,List<Item> *fields,
                                  fields);
       rc= join->result->send_data(*columns_list);
     }
+    /*
+      An error can happen when evaluating the conds 
+      (the join condition and piece of where clause 
+      relevant to this join table).
+    */
+    if (join->thd->is_error())
+      error= NESTED_LOOP_ERROR;
   }
   else
   {


Attachment: [text/bzr-bundle] bzr/magne.mahre@sun.com-20090920144251-fftf871xi0qu2j3p.bundle
Thread
bzr commit into mysql-6.0-bugfixing branch (magne.mahre:2826) Bug#46374Magne Mahre20 Sep