Commit b6ef08bb authored by Ramil Kalimullin's avatar Ramil Kalimullin

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.
parent 73a5527e
......@@ -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
# ------------------------------------------------------------------
......@@ -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 # ------------------------------------------------------------------
......@@ -155,13 +155,11 @@ bool Item_subselect::fix_fields(THD *thd_param, Item **ref)
if (check_stack_overrun(thd, STACK_MIN_SIZE, (uchar*)&res))
return TRUE;
res= engine->prepare();
if (!(res= engine->prepare()))
{
// all transformation is done (used by prepared statements)
changed= 1;
if (!res)
{
if (substitution)
{
int ret= 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment