• Vicențiu Ciorbaru's avatar
    MDEV-10815: Window Function Expressions Wrong Results · 2857ff3c
    Vicențiu Ciorbaru authored
    Fix window function expressions such as win_func() <operator> expr.
    The problem was found in 2 places.
    First, when we have complex expressions containing window functions, we
    can only compute their final value _after_ we have computed the window
    function's values. These values must be stored within the temporary
    table that we are using, before sending them off.
    This is done by performing an extra copy_funcs call before the final
    end_send() call.
    
    Second, such expressions need to have their inner arguments,
    changed such that the references within those arguments point to fields within
    the temporary table.
    Ex: sum(t.a) over (order by t.b) + sum(t.a) over (order by t.b)
    Before this fix, t.a pointed to the original table's a field. In order
    to compute the sum function's value correctly, it needs to point to the
    copy of this field inside the temp table.
    This is done by calling split_sum_func for each argument in the
    expression in turn.
    
    The win.test results have also been updated as they contained wrong
    values for such a use case.
    2857ff3c
item.cc 278 KB