diff options
author | Galina Shalygina <galina.shalygina@mariadb.org> | 2019-04-22 16:19:55 +0300 |
---|---|---|
committer | Galina Shalygina <galina.shalygina@mariadb.org> | 2019-04-22 16:19:55 +0300 |
commit | a765b19e5ca31a3d866cdbc8bef3a6f4e5e44688 (patch) | |
tree | 426a93041b1409ae5e99b4052ed601fcf38c8315 /sql/opt_subselect.cc | |
parent | a65d3b2c1633cbb21a9ab4b61d1bcd865e3c3219 (diff) | |
download | mariadb-git-a765b19e5ca31a3d866cdbc8bef3a6f4e5e44688.tar.gz |
MDEV-19245: Impossible WHERE should be noticed earlier after HAVING pushdownbb-10.4-galina
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.
Diffstat (limited to 'sql/opt_subselect.cc')
-rw-r--r-- | sql/opt_subselect.cc | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index 32b70b41eb3..2fedd8a4ed3 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -5723,12 +5723,6 @@ Item *and_new_conditions_to_optimized_cond(THD *thd, Item *cond, &((Item_cond_and *) cond)->m_cond_equal, false, NULL); } - /* - Check if equalities that can't be transformed into multiple - equalities are knowingly true or false. - */ - if (item->const_item() && !item->val_int()) - is_simplified_cond= true; and_args->push_back(item, thd->mem_root); } and_args->append((List<Item> *) cond_equalities); @@ -5821,12 +5815,6 @@ Item *and_new_conditions_to_optimized_cond(THD *thd, Item *cond, { item= item->build_equal_items(thd, inherited, false, NULL); } - /* - Check if equalities that can't be transformed into multiple - equalities are knowingly true or false. - */ - if (item->const_item() && !item->val_int()) - is_simplified_cond= true; new_conds_list.push_back(item, thd->mem_root); } new_conds_list.append((List<Item> *)&new_cond_equal.current_level); @@ -5870,7 +5858,14 @@ Item *and_new_conditions_to_optimized_cond(THD *thd, Item *cond, cond= cond->propagate_equal_fields(thd, Item::Context_boolean(), *cond_eq); + cond->update_used_tables(); } + /* Check if conds has knowingly true or false parts. */ + if (cond && + !is_simplified_cond && + cond->walk(&Item::is_simplified_cond_processor, 0, 0)) + is_simplified_cond= true; + /* If it was found that there are some knowingly true or false equalities |