diff options
author | unknown <timour@askmonty.org> | 2011-08-23 15:39:15 +0300 |
---|---|---|
committer | unknown <timour@askmonty.org> | 2011-08-23 15:39:15 +0300 |
commit | c1a6dbe5b26946fd40a73dfd4b72c3f6f6f6ae5f (patch) | |
tree | e26d75d70d6a0199e64ab57f7c081f52cb71fcf0 /mysql-test/r/subselect4.result | |
parent | 9e60b55fd0ff37527ca83e590d1c5386dfa788d6 (diff) | |
download | mariadb-git-c1a6dbe5b26946fd40a73dfd4b72c3f6f6f6ae5f.tar.gz |
Fixed bug lp:825018
Analysis:
During the first execution of the query through the stored
procedure, the optimization phase calls
substitute_for_best_equal_field(), which calls
Item_in_optimizer::transform(). The latter replaces
Item_in_subselect::left_expr with args[0] via assignment.
In this test case args[0] is an Item_outer_ref which is
created/deallocated for each re-execution. As a result,
during the second execution Item_in_subselect::left_expr
pointed to freed memory, which resulted in a crash.
Solution:
The solution is to use change_item_tree(), so that the
origianal left expression is restored after each execution.
Diffstat (limited to 'mysql-test/r/subselect4.result')
-rw-r--r-- | mysql-test/r/subselect4.result | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/mysql-test/r/subselect4.result b/mysql-test/r/subselect4.result index 686c8df0ea6..e41aa372816 100644 --- a/mysql-test/r/subselect4.result +++ b/mysql-test/r/subselect4.result @@ -2090,4 +2090,42 @@ EXECUTE st2; f2 2 drop table t1, t2; +# +# LP BUG#825018: Crash in check_and_do_in_subquery_rewrites() with corrlated subquery in select list +# +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (10,1),(11,7); +CREATE TABLE t2 (a int); +INSERT INTO t2 VALUES (2),(3); +CREATE TABLE t3 (a int, b int); +INSERT INTO t3 VALUES (1,1); +CREATE PROCEDURE sp1 () LANGUAGE SQL +SELECT (SELECT t1.a +FROM t1 +WHERE t1.b = t3.b +AND t1.b IN ( SELECT a FROM t2 )) sq +FROM t3 +GROUP BY 1; +CALL sp1(); +sq +NULL +CALL sp1(); +sq +NULL +drop procedure sp1; +prepare st1 from " +SELECT (SELECT t1.a + FROM t1 + WHERE t1.b = t3.b + AND t1.b IN ( SELECT a FROM t2 )) sq +FROM t3 +GROUP BY 1"; +execute st1; +sq +NULL +execute st1; +sq +NULL +deallocate prepare st1; +drop table t1, t2, t3; set optimizer_switch=@subselect4_tmp; |