Bug #48868 | Left outer join in subquery causes segmentation fault in make_join_select | ||
---|---|---|---|
Submitted: | 18 Nov 2009 15:42 | Modified: | 22 Nov 2010 0:52 |
Reporter: | Øystein Grøvlen | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S3 (Non-critical) |
Version: | 6.0 | OS: | Any |
Assigned to: | Tor Didriksen | CPU Architecture: | Any |
Tags: | crash, materialization, optimizer_switch, outerjoin, semijoin, subquery |
[18 Nov 2009 15:42]
Øystein Grøvlen
[22 Dec 2009 10:51]
Øystein Grøvlen
This issue is also reproducible with the test case below. It seems the requirement for reproducing the bug with the below queyr is that table t2 has one row. Sizes of t1 and t3 is irrelevant, it seems. CREATE TABLE t1 (i INTEGER); INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (2); CREATE TABLE t2 (i INTEGER); INSERT INTO t2 VALUES(1); CREATE TABLE t3 (i INTEGER); INSERT INTO t3 VALUES (1); INSERT INTO t3 VALUES (2); SELECT * FROM t1 WHERE (t1.i) IN (SELECT t2.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
[22 Dec 2009 11:01]
Øystein Grøvlen
This problem with left outer join in IN-subqueries that surfaces when the left table pulled out because it is constant (one row). The problem is related to a loop at the end of make_join_select for (tab= join->join_tab+join->const_tables; tab <= last_tab ; tab++) The problem is that the 'tab' loop variable is also the loop variable of an outer loop. There is code below this inner loop that uses tab that gets into trouble because of this. The inner loop is only used for inner tables of outer joins. Hence the problem only surfaces for outer joins.
[29 Dec 2009 13:41]
Øystein Grøvlen
This bug is now visible in mysql-6.0-codebase-bugfixing since bug#46692 has now been fixed. Requesting retriage since previous triage was based on that it was only visible in private branch. Reassigning this to Tor since he has a fix ready.
[29 Dec 2009 16:09]
Øystein Grøvlen
A test case in subselect_sj.test has been disabled due to this but. Please, enable it as part of fixing this bug. I also suggest adding the query from the above test case to the same loop of subselect_sj.test. That is, SELECT * FROM t1 WHERE (t1.i) IN (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
[5 Jan 2010 10:50]
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/95945 3807 Tor Didriksen 2010-01-05 Bug #48868 Left outer join in subquery causes segmentation fault in make_join_select This problem with left outer join in IN-subqueries that surfaced when the left table was pulled out because it was constant (one row). The problem was related to a loop at the end of make_join_select for (tab= join->join_tab+join->const_tables; tab <= last_tab ; tab++) The problem was that the 'tab' loop variable was also the loop variable of an outer loop. There was code below this inner loop that used tab that gets into trouble because of this. The inner loop was only used for inner tables of outer joins. Hence the problem only surfaced for outer joins. Solution: split make_join_select() in two, and put the condition-push-down code into a separate utility function. @ mysql-test/r/subselect_sj.result Add test case result. @ mysql-test/r/subselect_sj_jcl6.result Add test case result. @ mysql-test/t/subselect_sj.test Add test case. @ sql/sql_select.cc Split make_join_select() in two, and put the condition-push-down code into a separate utility function pushdown_conditions().
[6 Jan 2010 10:00]
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/96085 3808 Tor Didriksen 2010-01-05 Bug #48868 Left outer join in subquery causes segmentation fault in make_join_select This problem with left outer join in IN-subqueries that surfaced when the left table was pulled out because it was constant (one row). The problem was related to a loop at the end of make_join_select for (tab= join->join_tab+join->const_tables; tab <= last_tab ; tab++) The problem was that the 'tab' loop variable was also the loop variable of an outer loop. There was code below this inner loop that used tab that gets into trouble because of this. The inner loop was only used for inner tables of outer joins. Hence the problem only surfaced for outer joins. Solution: split make_join_select() in two, and put the condition-push-down code into a separate utility function. @ mysql-test/r/subselect_sj.result Add test case result. @ mysql-test/r/subselect_sj_jcl6.result Add test case result. @ mysql-test/t/subselect_sj.test Add test case. @ sql/sql_select.cc Split make_join_select() in two, and put the condition-push-down code into a separate utility function pushdown_conditions().
[7 Jan 2010 13:49]
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/96261 3815 Tor Didriksen 2010-01-07 Bug #48868 Left outer join in subquery causes segmentation fault in make_join_select This problem with left outer join in IN-subqueries that surfaced when the left table was pulled out because it was constant (one row). The problem was related to a loop at the end of make_join_select for (tab= join->join_tab+join->const_tables; tab <= last_tab ; tab++) The problem was that the 'tab' loop variable was also the loop variable of an outer loop. There was code below this inner loop that used tab that gets into trouble because of this. The inner loop was only used for inner tables of outer joins. Hence the problem only surfaced for outer joins. Solution: split make_join_select() in two, and put the condition-push-down code into a separate utility function. @ mysql-test/r/subselect_sj.result Add test case result. @ mysql-test/r/subselect_sj_jcl6.result Add test case result. @ mysql-test/t/subselect_sj.test Add test case. @ sql/sql_select.cc Split make_join_select() in two, and put the condition-push-down code into a separate utility function pushdown_conditions().
[8 Jan 2010 9:38]
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/96353 3815 Tor Didriksen 2010-01-08 Bug #48868 Left outer join in subquery causes segmentation fault in make_join_select This problem with left outer join in IN-subqueries that surfaced when the left table was pulled out because it was constant (one row). The problem was related to a loop at the end of make_join_select for (tab= join->join_tab+join->const_tables; tab <= last_tab ; tab++) The problem was that the 'tab' loop variable was also the loop variable of an outer loop. There was code below this inner loop that used tab that gets into trouble because of this. The inner loop was only used for inner tables of outer joins. Hence the problem only surfaced for outer joins. Solution: split make_join_select() in two, and put the condition-push-down code into a separate utility function. @ mysql-test/r/subselect_sj.result Add test case result. @ mysql-test/r/subselect_sj_jcl6.result Add test case result. @ mysql-test/t/subselect_sj.test Add test case. @ sql/sql_select.cc Split make_join_select() in two, and put the condition-push-down code into a separate utility function pushdown_on_conditions().
[8 Jan 2010 9:47]
Tor Didriksen
pushed to bzr+ssh://bk-internal.mysql.com/bzrroot/server/mysql-6.0-codebase-bugfixing/
[12 Jan 2010 16:24]
Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100112162328-2sblcul1kl08bbib) (version source revid:guilhem@mysql.com-20100108092756-k0zzf4kvx9b7bh38) (merge vers: 6.0.14-alpha) (pib:15)
[23 Jan 2010 0:31]
Paul DuBois
Appears only when fix for Bug#46692 is applied, which is in the same release tree. Hence, this bug does not appear in any released version and no changelog entry is needed.
[12 May 2010 14:12]
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/108151 3169 Tor Didriksen 2010-05-12 Bug #48868 Left outer join in subquery causes segmentation fault in make_join_select Backport of tor.didriksen@sun.com-20100108093836-405e9flc3x1egvbt This problem with left outer join in IN-subqueries that surfaced when the left table was pulled out because it was constant (one row). The problem was related to a loop at the end of make_join_select for (tab= join->join_tab+join->const_tables; tab <= last_tab ; tab++) The problem was that the 'tab' loop variable was also the loop variable of an outer loop. There was code below this inner loop that used tab that gets into trouble because of this. The inner loop was only used for inner tables of outer joins. Hence the problem only surfaced for outer joins. Solution: split make_join_select() in two, and put the condition-push-down code into a separate utility function. @ mysql-test/r/subselect_sj.result Add test case result. @ mysql-test/r/subselect_sj_jcl6.result Add test case result. @ mysql-test/t/subselect_sj.test Add test case. @ sql/sql_select.cc Split make_join_select() in two, and put the condition-push-down code into a separate utility function pushdown_on_conditions().
[16 Aug 2010 6:39]
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:14]
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)
[22 Nov 2010 1:02]
Paul DuBois
Not in any released 5.6.x version. No changelog entry needed.