Bug #49630 | Segfault in select_describe() with double nested subquery and materialization | ||
---|---|---|---|
Submitted: | 11 Dec 2009 16:30 | Modified: | 23 Nov 2010 3:09 |
Reporter: | Patrick Crews | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S3 (Non-critical) |
Version: | 6.0 | OS: | Any |
Assigned to: | Jørgen Løland | CPU Architecture: | Any |
Tags: | materialization, optimizer_switch, semijoin |
[11 Dec 2009 16:30]
Patrick Crews
[11 Dec 2009 16:32]
Patrick Crews
Full crash output
Attachment: bug49630_crash_output.txt (text/plain), 12.45 KiB.
[8 Jan 2010 10:28]
Jørgen Løland
Simplified test case: --------------------- CREATE TABLE t1 ( t1i int ); INSERT INTO t1 VALUES (1); CREATE TABLE t2 ( t2i int ); INSERT INTO t2 VALUES (2); INSERT INTO t2 VALUES (3); CREATE TABLE t3 ( t3i int ); INSERT INTO t3 VALUES (4); EXPLAIN SELECT t1i FROM t1 JOIN t3 ON t1i=t3i WHERE (1) IN ( SELECT t1i FROM t1 WHERE (t1i) IN ( SELECT t2i FROM t2 GROUP BY t2i) );
[24 Feb 2010 17:57]
MySQL Verification Team
After a full review procedure, I fully endorse Jørgen's patch. It is only possible that some of the old tests has to be changed, which I did not check.
[4 Mar 2010 9:59]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/102261 2995 Jorgen Loland 2010-03-04 Bug#49630 "Segfault in select_describe() with double nested subquery and materialization" If a JOIN contains const tables, make_join_select() will evaluate the conditions in the WHERE clause. If the WHERE clause contains a subquery, the process of evaluating the condition involves optimize() and exec(). Calling optimize() and exec() on a subselect may require the use of temp tables, in which case the original JOIN query execution plan will be replaced by a simple scan of the temp table. To be able to describe the query plan, the original query layout needs to be saved. This was not done for materialized subqueries. The fix is to make materialized subqueries save the original join query layout if it is needed by EXPLAIN. @ mysql-test/r/subselect4.result Added test for BUG#49630 @ mysql-test/t/subselect4.test Added test for BUG#49630 @ sql/item_subselect.cc Make subselect_hash_sj_engine::exec save JOIN layout if needed by explain. Added function subselect_single_select_engine::save_join_if_explain() with code common to single_select_engine and hash_sj_engine @ sql/item_subselect.h Add function subselect_single_select_engine::save_join_if_explain() that saves the JOIN layout if needed by explain
[15 Mar 2010 7:52]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/103175 3821 Jorgen Loland 2010-03-15 Bug#49630 "Segfault in select_describe() with double nested subquery and materialization" If a JOIN contains const tables, make_join_select() will evaluate the conditions in the WHERE clause. If the WHERE clause contains a subquery, the process of evaluating the condition involves optimize() and exec(). Calling optimize() and exec() on a subselect may require the use of temp tables, in which case the original JOIN query execution plan will be replaced by a simple scan of the temp table. To be able to describe the query plan, the original query layout needs to be saved. This was not done for materialized subqueries. The fix is to make materialized subqueries save the original join query layout if it is needed by EXPLAIN. @ mysql-test/r/subselect4.result Added test for BUG#49630 @ mysql-test/t/subselect4.test Added test for BUG#49630 @ sql/item_subselect.cc Make subselect_hash_sj_engine::exec save JOIN layout if needed by explain. Added function subselect_single_select_engine::save_join_if_explain() with code common to single_select_engine and hash_sj_engine @ sql/item_subselect.h Add function subselect_single_select_engine::save_join_if_explain() that saves the JOIN layout if needed by explain
[15 Mar 2010 7:53]
Jørgen Løland
Pushed to 6.0-codebase-bugfixing
[24 Mar 2010 8:14]
Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100324081249-yfwol7qtcek6dh7w) (version source revid:alik@sun.com-20100324081113-kc7x1iytnplww91u) (merge vers: 6.0.14-alpha) (pib:16)
[7 Apr 2010 12:05]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/105152 3069 oystein.grovlen@sun.com 2010-04-07 Bug#49630 "Segfault in select_describe() with double nested subquery and materialization" (Backporting of revid:jorgen.loland@sun.com-20100315075225-rcwlxcsuuidwnwzi) If a JOIN contains const tables, make_join_select() will evaluate the conditions in the WHERE clause. If the WHERE clause contains a subquery, the process of evaluating the condition involves optimize() and exec(). Calling optimize() and exec() on a subselect may require the use of temp tables, in which case the original JOIN query execution plan will be replaced by a simple scan of the temp table. To be able to describe the query plan, the original query layout needs to be saved. This was not done for materialized subqueries. The fix is to make materialized subqueries save the original join query layout if it is needed by EXPLAIN. @ mysql-test/r/subselect4.result Added test for BUG#49630 @ mysql-test/t/subselect4.test Added test for BUG#49630 @ sql/item_subselect.cc Make subselect_hash_sj_engine::exec save JOIN layout if needed by explain. Added function subselect_single_select_engine::save_join_if_explain() with code common to single_select_engine and hash_sj_engine @ sql/item_subselect.h Add function subselect_single_select_engine::save_join_if_explain() that saves the JOIN layout if needed by explain
[26 Apr 2010 14:21]
Paul DuBois
Noted in 6.0.14 changelog. EXPLAIN for queries with subqueries evaluated using materialization (with the result stored in a temporary table) caused a server crash.
[16 Aug 2010 6:31]
Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100816062819-bluwgdq8q4xysmlg) (version source revid:alik@sun.com-20100816062612-enatdwnv809iw3s9) (pib:20)
[13 Nov 2010 16:10]
Bugs System
Pushed into mysql-trunk 5.6.99-m5 (revid:alexander.nozdrin@oracle.com-20101113155825-czmva9kg4n31anmu) (version source revid:vasil.dimov@oracle.com-20100629074804-359l9m9gniauxr94) (merge vers: 5.6.99-m4) (pib:21)
[23 Nov 2010 3:09]
Paul DuBois
Bug does not appear in any released 5.6.x version. No 5.6.1 changelog entry needed.