diff options
author | Igor Babaev <igor@askmonty.org> | 2017-02-09 19:33:28 -0800 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2017-02-09 19:34:01 -0800 |
commit | 78b5e8d6ca35be35cf2f10769c19cd7dacad09d2 (patch) | |
tree | c161313228a6dd6bae2964dc99f72c613e9f0d47 /sql/item_sum.cc | |
parent | 766ab173297b061f54476e5148da0ef02901d44f (diff) | |
download | mariadb-git-78b5e8d6ca35be35cf2f10769c19cd7dacad09d2.tar.gz |
Fixed bug mdev-11745.
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.
Diffstat (limited to 'sql/item_sum.cc')
-rw-r--r-- | sql/item_sum.cc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 2ca1be31ae1..098b1ea8750 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1161,7 +1161,8 @@ Item_sum_hybrid::fix_fields(THD *thd, Item **ref) case TIME_RESULT: DBUG_ASSERT(0); }; - setup_hybrid(thd, args[0], NULL); + if (!is_window_func_sum_expr()) + setup_hybrid(thd, args[0], NULL); /* MIN/MAX can return NULL for empty set indepedent of the used column */ maybe_null= 1; result_field=0; |