MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Ramil Kalimullin Date:September 4 2009 8:14am
Subject:bzr commit into mysql-5.1-bugteam branch (ramil:3108) Bug#46629
View as plain text  
#At file:///home/ram/mysql/b46629-5.1-bugteam/ based on revid:li-bing.song@stripped

 3108 Ramil Kalimullin	2009-09-04
      Fix for bug#46629: Item_in_subselect::val_int(): Assertion `0' 
      on subquery inside a SP 
      
      Problem: repeated call of a SP containing an incorrect query with a 
      subselect may lead to failed ASSERT().
      
      Fix: set proper sublelect's state in case of error occured during 
      subquery transformation.
     @ mysql-test/r/sp.result
        Fix for bug#46629: Item_in_subselect::val_int(): Assertion `0' 
        on subquery inside a SP 
          - test result.
     @ mysql-test/t/sp.test
        Fix for bug#46629: Item_in_subselect::val_int(): Assertion `0' 
        on subquery inside a SP 
          - test case.
     @ sql/item_subselect.cc
        Fix for bug#46629: Item_in_subselect::val_int(): Assertion `0' 
        on subquery inside a SP 
          - don't set Item_subselect::changed in the Item_subselect::fix_fields()
        if an error occured during subquery transformation.
        That prevents us of further processing incorrect subqueries after 
        Item_in_subselect::select_in_like_transformer().

    modified:
      mysql-test/r/sp.result
      mysql-test/t/sp.test
      sql/item_subselect.cc
=== modified file 'mysql-test/r/sp.result'
--- a/mysql-test/r/sp.result	2009-06-04 11:53:15 +0000
+++ b/mysql-test/r/sp.result	2009-09-04 08:14:54 +0000
@@ -6963,6 +6963,22 @@ CALL p1();
 CALL p1();
 DROP PROCEDURE p1;
 DROP TABLE t1;
+#
+# Bug #46629: Item_in_subselect::val_int(): Assertion `0' 
+# on subquery inside a SP
+#
+CREATE TABLE t1(a INT);
+CREATE TABLE t2(a INT, b INT PRIMARY KEY);
+CREATE PROCEDURE p1 () 
+BEGIN 
+SELECT a FROM t1 A WHERE A.b IN (SELECT b FROM t2 AS B);
+END|
+CALL p1;
+ERROR 42S22: Unknown column 'A.b' in 'IN/ALL/ANY subquery'
+CALL p1;
+ERROR 42S22: Unknown column 'A.b' in 'IN/ALL/ANY subquery'
+DROP PROCEDURE p1;
+DROP TABLE t1, t2;
 # ------------------------------------------------------------------
 # -- End of 5.1 tests
 # ------------------------------------------------------------------

=== modified file 'mysql-test/t/sp.test'
--- a/mysql-test/t/sp.test	2009-06-04 11:53:15 +0000
+++ b/mysql-test/t/sp.test	2009-09-04 08:14:54 +0000
@@ -8242,6 +8242,28 @@ while ($tab_count)
 DROP PROCEDURE p1;
 DROP TABLE t1;
 
+
+--echo #
+--echo # Bug #46629: Item_in_subselect::val_int(): Assertion `0' 
+--echo # on subquery inside a SP
+--echo #
+CREATE TABLE t1(a INT);
+CREATE TABLE t2(a INT, b INT PRIMARY KEY);
+
+DELIMITER |;
+CREATE PROCEDURE p1 () 
+BEGIN 
+  SELECT a FROM t1 A WHERE A.b IN (SELECT b FROM t2 AS B);
+END|
+DELIMITER ;|
+--error ER_BAD_FIELD_ERROR
+CALL p1;
+--error ER_BAD_FIELD_ERROR
+CALL p1;
+DROP PROCEDURE p1;
+DROP TABLE t1, t2;
+
+
 --echo # ------------------------------------------------------------------
 --echo # -- End of 5.1 tests
 --echo # ------------------------------------------------------------------

=== modified file 'sql/item_subselect.cc'
--- a/sql/item_subselect.cc	2009-07-19 12:49:40 +0000
+++ b/sql/item_subselect.cc	2009-09-04 08:14:54 +0000
@@ -155,13 +155,11 @@ bool Item_subselect::fix_fields(THD *thd
   if (check_stack_overrun(thd, STACK_MIN_SIZE, (uchar*)&res))
     return TRUE;
 
-  res= engine->prepare();
-
-  // all transformation is done (used by prepared statements)
-  changed= 1;
-
-  if (!res)
+  if (!(res= engine->prepare()))
   {
+    // all transformation is done (used by prepared statements)
+    changed= 1;
+
     if (substitution)
     {
       int ret= 0;


Attachment: [text/bzr-bundle] bzr/ramil@mysql.com-20090904081454-hwwqvzlaiirnz0e4.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (ramil:3108) Bug#46629Ramil Kalimullin4 Sep