summaryrefslogtreecommitdiff
path: root/sql/item_windowfunc.cc
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2017-02-09 19:33:28 -0800
committerIgor Babaev <igor@askmonty.org>2017-02-09 19:34:01 -0800
commit78b5e8d6ca35be35cf2f10769c19cd7dacad09d2 (patch)
treec161313228a6dd6bae2964dc99f72c613e9f0d47 /sql/item_windowfunc.cc
parent766ab173297b061f54476e5148da0ef02901d44f (diff)
downloadmariadb-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_windowfunc.cc')
-rw-r--r--sql/item_windowfunc.cc1
1 files changed, 1 insertions, 0 deletions
diff --git a/sql/item_windowfunc.cc b/sql/item_windowfunc.cc
index a13967eaaad..fb2ad666018 100644
--- a/sql/item_windowfunc.cc
+++ b/sql/item_windowfunc.cc
@@ -150,6 +150,7 @@ void Item_window_func::split_sum_func(THD *thd, Ref_ptr_array ref_pointer_array,
Item **p_item= &window_func()->arguments()[i];
(*p_item)->split_sum_func2(thd, ref_pointer_array, fields, p_item, flags);
}
+ window_func()->setup_caches(thd);
}