• Sergei Petrunia's avatar
    MDEV-30605: Wrong result while using index for group-by · be7ef656
    Sergei Petrunia authored
    A GROUP BY query which uses "MIN(pk)" and has "pk<>const" in the
    WHERE clause would produce wrong result when handled with "Using index
    for group-by".  Here "pk" column is the table's primary key.
    
    The problem was introduced by fix for MDEV-23634. It made the range
    optimizer to not produce ranges for conditions in form "pk != const".
    
    However, LooseScan code requires that the optimizer is able to
    convert the condition on the MIN/MAX column into an equivalent range.
    The range is used to locate the row that has the MIN/MAX value.
    
    LooseScan checks this in check_group_min_max_predicates(). This fix
    makes the code in that function to take into account that "pk != const"
    does not produce a range.
    be7ef656
group_min_max.result 141 KB