summaryrefslogtreecommitdiff
path: root/mysql-test/main/having_cond_pushdown.result
Commit message (Collapse)AuthorAgeFilesLines
* Merge 10.7 into 10.8Marko Mäkelä2022-07-281-2/+2
|\
| * Merge branch '10.3' into 10.4Oleksandr Byelkin2022-07-271-2/+2
| |
* | Merge branch '10.7' into 10.8Sergei Golubchik2022-05-111-0/+46
|\ \ | |/
| * MDEV-28080 Crash when using HAVING with NOT EXIST predicate in an equalityIgor Babaev2022-04-291-0/+31
| | | | | | | | | | | | | | MDEV-28082 Crash when using HAVING with IS NULL predicate in an equality These bugs have been fixed by the patch for MDEV-26402. Only test cases are added.
| * MDEV-26402: A SEGV in Item_field::used_tables/update_depend_map_for_order...Sergei Petrunia2022-04-221-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When doing condition pushdown from HAVING into WHERE, Item_equal::create_pushable_equalities() calls item->set_extraction_flag(IMMUTABLE_FL) for constant items. Then, Item::cleanup_excluding_immutables_processor() checks for this flag to see if it should call item->cleanup() or leave the item as-is. The failure happens when a constant item has a non-constant one inside it, like: (tbl.col=0 AND impossible_cond) item->walk(cleanup_excluding_immutables_processor) works in a bottom-up way so it 1. will call Item_func_eq(tbl.col=0)->cleanup() 2. will not call Item_cond_and->cleanup (as the AND is constant) This creates an item tree where a fixed Item has an un-fixed Item inside it which eventually causes an assertion failure. Fixed by introducing this rule: instead of just calling item->set_extraction_flag(IMMUTABLE_FL); we call Item::walk() to set the flag for all sub-items of the item.
* | MDEV-27036: resolve duplicated key issues of JSON tracing outputs:Sergei Krivonos2021-11-261-1144/+1744
|/ | | | | | | | | | | MDEV-27036: repeated "table" key resolve for print_explain_json MDEV-27036: duplicated keys in best_access_path MDEV-27036: Explain_aggr_filesort::print_json_members: resolve duplicated "filesort" member in Json object MDEV-27036: Explain_basic_join:: print_explain_json_interns fixed start_dups_weedout case for main.explain_json test
* MDEV-21184 Assertion `used_tables_cache == 0' failed in Item_func::fix_fieldsIgor Babaev2020-01-151-0/+148
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | with condition_pushdown_from_having This bug could manifest itself for queries with GROUP BY and HAVING clauses when the HAVING clause was a conjunctive condition that depended exclusively on grouping fields and at least one conjunct contained an equality of the form fld=sq where fld is a grouping field and sq is a constant subquery. In this case the optimizer tries to perform a pushdown of the HAVING condition into WHERE. To construct the pushable condition the optimizer first transforms all multiple equalities in HAVING into simple equalities. This has to be done for a proper processing of the pushed conditions in WHERE. The multiple equalities at all AND/OR levels must be converted to simple equalities because any multiple equality may refer to a multiple equality at the upper level. Before this patch the conversion was performed like this: multiple_equality(x,f1,...,fn) => x=f1 and ... and x=fn. When an equality item for x=fi was constructed both the items for x and fi were cloned. If x happened to be a constant subquery that could not be cloned the conversion failed. If the conversions of multiple equalities previously performed had succeeded then the whole condition became in an inconsistent state that could cause different failures. The solution provided by the patch is: 1. to use a different conversion rule if x is a constant multiple_equality(x,f1,...,fn) => f1=x and f2=f1 and ... and fn=f1 2. not to clone x if it's a constant. Such conversions cannot fail and besides the result of the conversion preserves the equivalence of f1,...,fn that can be used for other optimizations. This patch also made sure that expensive predicates are not pushed from HAVING to WHERE.
* MDEV-19245: Impossible WHERE should be noticed earlier after HAVING pushdownbb-10.4-galinaGalina Shalygina2019-04-221-0/+43
| | | | | | | | The bug appears because not all conditions are found to be knowingly true or false in WHERE after HAVING pushdown optimization. Impossible WHERE can be found much earlier compared with how it is done now. To fix it and_new_conditions_to_optimized_cond() is changed.
* MDEV-19164 Assertion `fixed' failed in Item_func_inet_aton::val_intIgor Babaev2019-04-171-0/+76
| | | | | | | | | | | | | | | | | | | When pushing a condition from HAVING into WHERE the function st_select_lex::pushdown_from_having_into_where() transforms column references in the pushed condition then performs cleanup of items of the condition and finally calls fix_fields() for the condition items. The cleanup is performed by a call of the method walk() with cleanup_processor as the first parameter. Unfortunately this sequence of calls does not work if the condition contains cached items, because fix_fields() cannot go through Item_cache items and this leaves underlying items unfixed. The solution of this problem used in this patch is just does not allow to process Item_cache objects when performing cleanup of the pushed condition. In order to let the traversal procedure walk() not to process Item_cache objects the third parameter of the used call of walk() is set to a fictitious pointer (void *) 1. And Item_cache::walk() is changed to prevent any action when it gets such value as the third parameter.
* MDEV-19186: Assertion `field->table == table' failed in create_tmp_tableGalina Shalygina2019-04-061-0/+16
| | | | | | | Temporary table is defined with the view field in HAVING. Item_direct_view_ref for this field is dropped and that causes error. To fix it Item_direct_view_ref::remove_item_direct_ref() is added.
* MDEV-19185: Pushdown constant function defined with subqueryGalina Shalygina2019-04-051-0/+16
| | | | | | | | | The bug occurs because of the wrong pushdown of constant function defined with subquery from HAVING into WHERE. Subqueries can't be pushed into WHERE. To fix it with_subquery() call is added to check if the function contains subquery.
* MDEV-18769 Assertion `fixed == 1' failed in Item_cond_or::val_intGalina Shalygina2019-04-041-1/+2708
| | | | | | | | | | | | | | | | | | This bug is caused by pushdown from HAVING into WHERE. It appears because condition that is pushed wasn't fixed. It is also discovered that condition pushdown from HAVING into WHERE is done wrong. There is no need to build clones for some conditions that can be pushed. They can be simply moved from HAVING into WHERE without cloning. build_pushable_cond_for_having_pushdown(), remove_pushed_top_conjuncts_for_having() methods are changed. It is found that there is no transformation made for fields of pushed condition. field_transformer_for_having_pushdown transformer is added. New tests are added. Some comments are changed.
* MDEV-18668 Server crash or ASAN use-after-poison in Item_equal_iterator /Igor Babaev2019-02-241-0/+12
| | | | | | | st_select_lex::pushdown_from_having_into_where upon query with impossible WHERE condition Do not push from HAVING into impossible WHERE
* MDEV-7486: Condition pushdown from HAVING into WHEREIgor Babaev2019-02-191-1/+1
| | | | | | Optimized the code that removed multiple equalities pushed from HAVING into WHERE. Now this removal is postponed until all multiple equalities are eliminated in substitute_for_best_equal_field().
* MDEV-7486: Condition pushdown from HAVING into WHEREGalina Shalygina2019-02-171-0/+1908
Condition can be pushed from the HAVING clause into the WHERE clause if it depends only on the fields that are used in the GROUP BY list or depends on the fields that are equal to grouping fields. Aggregate functions can't be pushed down. How the pushdown is performed on the example: SELECT t1.a,MAX(t1.b) FROM t1 GROUP BY t1.a HAVING (t1.a>2) AND (MAX(c)>12); => SELECT t1.a,MAX(t1.b) FROM t1 WHERE (t1.a>2) GROUP BY t1.a HAVING (MAX(c)>12); The implementation scheme: 1. Extract the most restrictive condition cond from the HAVING clause of the select that depends only on the fields that are used in the GROUP BY list of the select (directly or indirectly through equalities) 2. Save cond as a condition that can be pushed into the WHERE clause of the select 3. Remove cond from the HAVING clause if it is possible The optimization is implemented in the function st_select_lex::pushdown_from_having_into_where(). New test file having_cond_pushdown.test is created.