Bug #41842 | Semi-join materialization strategy crashes when the upper query has HAVING | ||
---|---|---|---|
Submitted: | 3 Jan 2009 18:29 | Modified: | 22 Nov 2010 1:41 |
Reporter: | Sergey Petrunya | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S3 (Non-critical) |
Version: | 6.0-bzr | OS: | Any |
Assigned to: | Sergey Petrunya | CPU Architecture: | Any |
Tags: | randgen |
[3 Jan 2009 18:29]
Sergey Petrunya
[3 Jan 2009 18:30]
Sergey Petrunya
Dataset
Attachment: bug41842.sql (, text), 4.02 KiB.
[3 Jan 2009 19:00]
Sergey Petrunya
Analysis -------- The problem is caused by the intersection of two properties 1. setup_sj_materialization() expects that equality propagation has created an Item_equal for the IN-equality and has put it into join->cond_equal. 2. optimize_cond() replaces join->cond_equal whenever it is invoked. JOIN::optimize() calls it for the WHERE clause, and then for HAVING. That is, if the query has HAVING, then setup_sj_materialization() will not be able to find the IN-equality in join->cond_equal (as it will have HAVING's equalities) and crash. This means three things: 1. Need to check what exactly is the purpose of putting HAVING's equalities into join->cond_equal. 2. Need to check if we want to have the dependency that every IN-equality must be usable for equality propagation. Probably, we don't 3. if the IN-equality *was* usable by equality propagation, then setup_sj_materialization does need to find the equality set. This is because it will need to unpack materialized columns into their original tblname.column_name, or, more precisely, into the first equality propagation-sibling of tblname.column_name, because this is where all conditions will refer to (see substitute_for_best_equal).
[25 Jan 2009 15:07]
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/63999 2808 Sergey Petrunia 2009-01-25 BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING - Make optimize_cond() not to do build_equal_items() for HAVING clause - Make setup_sj_materialization(), SJM-Scan setup code correctly pick an Item_equal element that sjm-scan should unpack values to.
[28 Jan 2009 17: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/64357 2817 Sergey Petrunia 2009-01-28 BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING - Make optimize_cond() not to do build_equal_items() for HAVING clause - Make setup_sj_materialization(), SJM-Scan setup code correctly pick an Item_equal element that sjm-scan should unpack values to.
[28 Jan 2009 19:25]
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/64378 2817 Sergey Petrunia 2009-01-28 BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING - Make optimize_cond() not to do build_equal_items() for HAVING clause - Make setup_sj_materialization(), SJM-Scan setup code correctly pick an Item_equal element that sjm-scan should unpack values to.
[2 Feb 2009 16:06]
Bugs System
Pushed into 6.0.10-alpha (revid:sergefp@mysql.com-20090202090240-dlkxhmc1asrar5rl) (version source revid:sergefp@mysql.com-20090128192454-ci4i10wrw69kwlv1) (merge vers: 6.0.10-alpha) (pib:6)
[11 Feb 2009 3:00]
Paul DuBois
Noted in 6.0.10 changelog. Queries executed using semi-join materialization could cause a crash if the outer query has a HAVING clause.
[24 Mar 2010 12:07]
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/104193 2854 Sergey Glukhov 2010-03-24 Bug#48971 Segfault in add_found_match_trig_cond () at sql_select.cc:5990 In case of simultaneous presence of WHERE and HAVING conds optimize_cond(and in their turn build_equal_items) is called twice. Second call may perform erroneous propagation of some expressions and further it may lead to crash. The fix is to make optimize_cond() not to do build_equal_items() for HAVING clause. Note: This fix is a partial backport of BUG#41842 patch. @ mysql-test/r/join.result test case @ mysql-test/t/join.test test case @ sql/sql_select.cc The fix is to make optimize_cond() not to do build_equal_items() for HAVING clause.
[16 Aug 2010 6:33]
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:19]
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:41]
Paul DuBois
Bug is not in any released 5.6.x version. No changelog entry needed.