summaryrefslogtreecommitdiff
path: root/sql/item_windowfunc.cc
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2019-08-07 22:44:54 +0400
committerAlexander Barkov <bar@mariadb.com>2019-08-07 22:44:54 +0400
commit7fc86a73d8fbfa6d527d9eb1160bedaf939eae7a (patch)
treeab1c8eb40c1638ad5134dac9c96d5aa45892c375 /sql/item_windowfunc.cc
parentd70dac207930ab74add149be692a775bc2952aaa (diff)
downloadmariadb-git-7fc86a73d8fbfa6d527d9eb1160bedaf939eae7a.tar.gz
MDEV-20272 PERCENTILE_DISC() crashes on a temporal type input
Diffstat (limited to 'sql/item_windowfunc.cc')
-rw-r--r--sql/item_windowfunc.cc33
1 files changed, 23 insertions, 10 deletions
diff --git a/sql/item_windowfunc.cc b/sql/item_windowfunc.cc
index 85e5144779e..98474f62d4f 100644
--- a/sql/item_windowfunc.cc
+++ b/sql/item_windowfunc.cc
@@ -172,25 +172,38 @@ void Item_window_func::split_sum_func(THD *thd, Ref_ptr_array ref_pointer_array,
bool Item_window_func::check_result_type_of_order_item()
{
- if (only_single_element_order_list())
+ switch (window_func()->sum_func()) {
+ case Item_sum::PERCENTILE_CONT_FUNC:
{
- Item *src_item= window_spec->order_list->first->item[0];
- Item_result rtype= src_item->cmp_type();
+ Item_result rtype= window_spec->order_list->first->item[0]->cmp_type();
// TODO (varun) : support date type in percentile_cont function
if (rtype != REAL_RESULT && rtype != INT_RESULT &&
rtype != DECIMAL_RESULT && rtype != TIME_RESULT)
{
my_error(ER_WRONG_TYPE_FOR_PERCENTILE_FUNC, MYF(0), window_func()->func_name());
- return TRUE;
+ return true;
}
- if (window_func()->sum_func() == Item_sum::PERCENTILE_DISC_FUNC)
+ return false;
+ }
+ case Item_sum::PERCENTILE_DISC_FUNC:
+ {
+ Item *src_item= window_spec->order_list->first->item[0];
+ Item_result rtype= src_item->cmp_type();
+ // TODO-10.5: Fix MDEV-20280 PERCENTILE_DISC() rejects temporal and string input
+ if (rtype != REAL_RESULT && rtype != INT_RESULT && rtype != DECIMAL_RESULT)
{
- Item_sum_percentile_disc *func=
- static_cast<Item_sum_percentile_disc*>(window_func());
- func->set_handler(src_item->type_handler());
- func->Type_std_attributes::set(src_item);
- Type_std_attributes::set(src_item);
+ my_error(ER_WRONG_TYPE_FOR_PERCENTILE_FUNC, MYF(0), window_func()->func_name());
+ return true;
}
+ Item_sum_percentile_disc *func=
+ static_cast<Item_sum_percentile_disc*>(window_func());
+ func->set_handler(src_item->type_handler());
+ func->Type_std_attributes::set(src_item);
+ Type_std_attributes::set(src_item);
+ return false;
+ }
+ default:
+ break;
}
return FALSE;
}