• Sergei Petrunia's avatar
    MDEV-26402: A SEGV in Item_field::used_tables/update_depend_map_for_order... · 807945f2
    Sergei Petrunia authored
    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.
    807945f2
item.h 241 KB