diff options
author | Vicențiu Ciorbaru <vicentiu@mariadb.org> | 2016-09-16 20:38:22 +0200 |
---|---|---|
committer | Vicențiu Ciorbaru <vicentiu@mariadb.org> | 2016-09-24 15:12:34 +0200 |
commit | 2857ff3c98cd2720d28aaf452f2c63ca7f98604b (patch) | |
tree | 370b53ce83ae1bc581827126bc5a1875abf45932 /sql/item_windowfunc.h | |
parent | 1c72441364157f6856406bbfc3a753868d33fbef (diff) | |
download | mariadb-git-2857ff3c98cd2720d28aaf452f2c63ca7f98604b.tar.gz |
MDEV-10815: Window Function Expressions Wrong Results
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.
Diffstat (limited to 'sql/item_windowfunc.h')
-rw-r--r-- | sql/item_windowfunc.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/sql/item_windowfunc.h b/sql/item_windowfunc.h index 433b3f6c4fd..3d4c310fa74 100644 --- a/sql/item_windowfunc.h +++ b/sql/item_windowfunc.h @@ -771,6 +771,7 @@ public: void split_sum_func(THD *thd, Ref_ptr_array ref_pointer_array, List<Item> &fields, uint flags); + void fix_length_and_dec() { decimals = window_func()->decimals; |