summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVarun Gupta <varunraiko1803@gmail.com>2017-07-17 15:08:08 +0530
committerVarun Gupta <varunraiko1803@gmail.com>2017-11-01 23:13:01 +0530
commit6511069e7fcf3c9035469f9d2996706fbde5d6a0 (patch)
tree200301c9d6ed70682193d456fb2852d90d7dd25d
parent947ce922c950323a91a187b53d3315b6e6a582f0 (diff)
downloadmariadb-git-6511069e7fcf3c9035469f9d2996706fbde5d6a0.tar.gz
Added the error ER_WRONG_TYPE_FOR_PERCENTILE_CONT, which ensures that the result type for percentile_cont is always numerical
-rw-r--r--sql/item_windowfunc.cc11
1 files changed, 4 insertions, 7 deletions
diff --git a/sql/item_windowfunc.cc b/sql/item_windowfunc.cc
index c860c5ead68..4022c3ddf70 100644
--- a/sql/item_windowfunc.cc
+++ b/sql/item_windowfunc.cc
@@ -178,25 +178,24 @@ void Item_window_func::split_sum_func(THD *thd, Ref_ptr_array ref_pointer_array,
window_func()->setup_caches(thd);
}
-bool Item_window_func::check_order_list()
+bool Item_window_func::check_result_type_of_order_item()
{
if (only_single_element_order_list())
{
Item_result rtype= window_spec->order_list->first->item[0]->result_type();
if (rtype != REAL_RESULT && rtype != INT_RESULT &&
- rtype != DECIMAL_RESULT)
+ rtype != DECIMAL_RESULT && window_func()->sum_func() == Item_sum::PERCENTILE_CONT_FUNC)
{
- // TODO(varun) please change the error name
- my_error(ER_WRONG_TYPE_FOR_RANGE_FRAME, MYF(0),"percentile functions");
+ my_error(ER_WRONG_TYPE_FOR_PERCENTILE_CONT, MYF(0));
return TRUE;
}
+ setting_handler_for_percentile_functions(rtype);
}
return FALSE;
}
/*
This must be called before attempting to compute the window function values.
-
@detail
If we attempt to do it in fix_fields(), partition_fields will refer
to the original window function arguments.
@@ -222,7 +221,6 @@ void Item_sum_dense_rank::setup_window_func(THD *thd, Window_spec *window_spec)
void Item_sum_percentile_disc::setup_window_func(THD *thd, Window_spec *window_spec)
{
order_item= window_spec->order_list->first->item[0];
- set_handler_by_cmp_type(order_item->result_type());
if (!(value= order_item->get_cache(thd)))
return;
value->setup(thd, order_item);
@@ -235,7 +233,6 @@ void Item_sum_percentile_cont::setup_window_func(THD *thd, Window_spec *window_s
/* TODO(varun): need to discuss and finalise what type should we
return for percentile cont functions
*/
- //set_handler_by_cmp_type(order_item->result_type());
if (!(ceil_value= order_item->get_cache(thd)))
return;
ceil_value->setup(thd, order_item);