• Varun Gupta's avatar
    MDEV-15454: Nested SELECT IN returns wrong results · 37dee22d
    Varun Gupta authored
    In this case we are setting the field Item_func_eq::in_eqaulity_no for the semi-join equalities.
    This helps us to remove these equalites as the inner tables are not available during parent select execution
    while the outer tables are not available during materialization phase.
    We only have it set for the equalites for the fields involved with the IN subquery
    and reset it for the equalities which do not belong to the IN subquery.
    
    For example in case of nested IN subqueries:
    
        SELECT t1.a FROM t1 WHERE t1.a IN
          (SELECT t2.a FROM t2 where t2.b IN
              (select t3.b from t3 where t3.c=27 ))
    
    there are two equalites involving the fields of the IN subquery
    
    1) t2.b = t3.b :  the field Item_func_eq::in_eqaulity_no is set when we merge the grandchild select into the child select
    2) t1.a = t2.a :  the field Item_func_eq::in_eqaulity_no is set when we merge the child select into the parent select
    
    But when we perform case 2) we should ensure that we reset the equalities in the child's WHERE clause.
    37dee22d
subselect_mat.result 132 KB