• Igor Babaev's avatar
    Fixed bug mdev-11745. · 78b5e8d6
    Igor Babaev authored
    Due to this bug many queries that contained a window function
    with MIN/MAX aggregation returned wrong results.
    
    Calculation of a MIN/MAX aggregate function uses cache objects
    and a comparator object that are created and set up in
    Item_sum_hybrid::fix_fields () by a call of Item_sum_hybrid::setup_hybrid().
    The latter binds the objects to the first argument of the
    MIN/MAX function. Meanwhile window function perform aggregation
    over fields of a temporary table. So binding must be done rather to
    these fields. The earliest moment when setup the objects used in
    MIN/max functions can be done is after all calls of the method
    split_sum_func().
    
    This patch introduces this late setup, but only for aggregate
    functions used in window functions.
    Probably it makes sense to use this late setup for all MIN/MAX
    objects.
    78b5e8d6
item_sum.h 56 KB