From: Date: August 7 2008 5:04pm Subject: bzr commit into mysql-5.0 branch (holyfoot:2653) Bug#37949 List-Archive: http://lists.mysql.com/commits/51122 X-Bug: 37949 Message-Id: <20080807150445.934722C380BB@hfmain.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit #At file:///home/hf/work/mysql_common/37949/ 2653 Alexey Botchkov 2008-08-07 Bug#37949 Crash if argument to SP is a subquery that returns more than one row JOIN for the subselect wasn't cleaned if we came upon an error during sub_select() execution. That leads to the assertion failure in close_thread_tables() per-file comments: mysql-test/r/sp-error.result Bug#37949 Crash if argument to SP is a subquery that returns more than one row test case mysql-test/t/sp-error.test Bug#37949 Crash if argument to SP is a subquery that returns more than one row test- result sql/item_subselect.cc Bug#37949 Crash if argument to SP is a subquery that returns more than one row subselect_single_select_engine::exec() modified. added join->cleanup() call after join->exec(). modified: mysql-test/r/sp-error.result mysql-test/t/sp-error.test sql/item_subselect.cc === modified file 'mysql-test/r/sp-error.result' --- a/mysql-test/r/sp-error.result 2008-01-23 20:26:41 +0000 +++ b/mysql-test/r/sp-error.result 2008-08-07 14:57:54 +0000 @@ -1513,3 +1513,10 @@ end loop label1; end loop; end| ERROR 42000: End-label label1 without match +CREATE TABLE t1 (a INT)| +INSERT INTO t1 VALUES (1),(2)| +CREATE PROCEDURE p1(a INT) BEGIN END| +CALL p1((SELECT * FROM t1))| +ERROR 21000: Subquery returns more than 1 row +DROP PROCEDURE p1| +DROP TABLE t1| === modified file 'mysql-test/t/sp-error.test' --- a/mysql-test/t/sp-error.test 2008-01-23 20:26:41 +0000 +++ b/mysql-test/t/sp-error.test 2008-08-07 14:57:54 +0000 @@ -2173,6 +2173,14 @@ begin end loop; end| +CREATE TABLE t1 (a INT)| +INSERT INTO t1 VALUES (1),(2)| +CREATE PROCEDURE p1(a INT) BEGIN END| +--error ER_SUBQUERY_NO_1_ROW +CALL p1((SELECT * FROM t1))| +DROP PROCEDURE p1| +DROP TABLE t1| + delimiter ;| # === modified file 'sql/item_subselect.cc' --- a/sql/item_subselect.cc 2008-03-28 11:31:52 +0000 +++ b/sql/item_subselect.cc 2008-08-07 14:57:54 +0000 @@ -1874,6 +1874,7 @@ int subselect_single_select_engine::exec } join->exec(); + join->cleanup(FALSE); /* Enable the optimizations back */ for (JOIN_TAB **ptab= changed_tabs; ptab != last_changed_tab; ptab++)