• unknown's avatar
    Fix LP BUG#777597 · 707e66e1
    unknown authored
    Analysis:
    During optimization of the subquery, in the call chain:
    
    update_ref_and_keys -> add_key_fields ->
    merge_key_fields -> Item_direct_ref::is_null -> Item_cache::is_null
    
    The call to Item_cache::is_null() returns TRUE, which is wrong.
    This results in Item_null replacing the field 'f3' in the KEY_FIELD,
    then this Item_null is used for index access, producing a wrong result.
    
    The reason why Item_cache::is_null returns wrong result is that
    this Item_cache object is a cache of the left operand of IN, and was
    updated in Item_in_optimizer::val_int. In MWL#89 the latter method is
    called during the execution phase, which is after we optimize the subquery.
    Therefore during the optization phase the left operand cache of IN was
    not updated.
    
    Solution:
    Update the left operand cache during optimization if it is a constant.
    
    This bug fix also discoveres and fixes a wrong IF statement in
    convert_constant_item().
    707e66e1
subselect4.result 71.6 KB