• Monty's avatar
    MDEV-27442 Wrong result upon query with DISTINCT and EXISTS subquery · d314bd26
    Monty authored
    The problem was that get_best_group_min_max() did not check if fields used
    by the "group_min_max optimization" where used in sub queries.
    Because of this, it did not detect that a key (b,a) was used in the WHERE
    clause for the statement:
    SELECT DISTINCT b FROM t1 WHERE EXISTS ( SELECT 1 FROM DUAL WHERE a > 1 ).
    
    Fixed by also traversing the sub queries when checking if a field is used.
    This disables group_min_max_optimization for the above query.
    
    Reviewer: Sergei Petrunia
    d314bd26
group_min_max.test 72.3 KB