• Sergei Petrunia's avatar
    MDEV-7691: Assertion `outer_context || !*from_field || *from_field == not_found_field' ... · 268bb69b
    Sergei Petrunia authored
    The bug occurred when a subquery
    - has a reference to outside, to grand-parent query or further up
    - is converted to a semi-join (i.e. merged into its parent).
    
    Then the reference to outside had form Item_ref(Item_field(...)).
    - Conversion to semi-join would call item->fix_after_pullout() for the
      outside reference.
    - Item_ref::fix_after_pullout would call Item_field->fix_after_pullout
    - The Item_field would construct a new Name_resolution_context object
      This process ignored the fact that the Item_field does not belong to
      any of the subselects being flattened.
    The result was crash in the next call to Item_field::fix_fields(), where
    we would try to use an invalid Name_resolution_context object.
    
    Fixed by not creating Name_resolution_context object if the Item_field's
    context does not belong to the subselect(s) that were flattened.
    268bb69b
item.cc 269 KB