From ae15f91f227015b3e1ad3f566db9396232cf0a3f Mon Sep 17 00:00:00 2001 From: Galina Shalygina Date: Sat, 23 Mar 2019 15:28:22 +0300 Subject: MDEV-18769 Assertion `fixed == 1' failed in Item_cond_or::val_int 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. --- sql/sql_derived.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'sql/sql_derived.cc') diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 1ad97e4244d..548383e818c 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -47,7 +47,6 @@ bool mysql_derived_fill(THD *thd, LEX *lex, TABLE_LIST *derived); bool mysql_derived_reinit(THD *thd, LEX *lex, TABLE_LIST *derived); bool mysql_derived_merge_for_insert(THD *thd, LEX *lex, TABLE_LIST *derived); - dt_processor processors[]= { &mysql_derived_init, @@ -1463,7 +1462,13 @@ bool pushdown_cond_for_derived(THD *thd, Item *cond, TABLE_LIST *derived) if (!remaining_cond) continue; - sl->mark_or_conds_to_avoid_pushdown(remaining_cond); + if (remaining_cond->walk(&Item::cleanup_excluding_const_fields_processor, + 0, 0)) + continue; + + mark_or_conds_to_avoid_pushdown(remaining_cond); + + sl->cond_pushed_into_having= remaining_cond; } thd->lex->current_select= save_curr_select; DBUG_RETURN(false); -- cgit v1.2.1