• Evgeny Potemkin's avatar
    Bug#50539: Wrong result when loose index scan is used for an aggregate · b5f40f34
    Evgeny Potemkin authored
               function with distinct.
    Loose index scan is used to find MIN/MAX values using appropriate index and
    thus allow to avoid grouping. For each found row it updates non-aggregated
    fields with values from row with found MIN/MAX value.
    Without loose index scan non-aggregated fields are copied by end_send_group
    function. With loose index scan there is no need in end_send_group and
    end_send is used instead. Non-aggregated fields still need to be copied and
    this was wrongly implemented in QUICK_GROUP_MIN_MAX_SELECT::get_next.
    WL#3220 added a case when loose index scan can be used with end_send_group to
    optimize calculation of aggregate functions with distinct. In this case
    the row found by QUICK_GROUP_MIN_MAX_SELECT::get_next might belong to a next
    group and copying it will produce wrong result.
    
    Update of non-aggregated fields is moved to the end_send function from
    QUICK_GROUP_MIN_MAX_SELECT::get_next.
    b5f40f34
group_min_max.test 54.7 KB