summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2019-08-07 21:01:22 +0400
committerAlexander Barkov <bar@mariadb.com>2019-08-07 21:01:22 +0400
commitd70dac207930ab74add149be692a775bc2952aaa (patch)
treea6642a2e788be0cc2a3edada3b376efb986ba21d /sql
parente978efd96b9a8146ba2c80a1f3aea755568ac73a (diff)
downloadmariadb-git-d70dac207930ab74add149be692a775bc2952aaa.tar.gz
MDEV-20278 PERCENTILE_DISC() returns a wrong data type
Diffstat (limited to 'sql')
-rw-r--r--sql/item_windowfunc.cc12
-rw-r--r--sql/item_windowfunc.h11
-rw-r--r--sql/sql_type.h4
3 files changed, 10 insertions, 17 deletions
diff --git a/sql/item_windowfunc.cc b/sql/item_windowfunc.cc
index 2db396d3065..85e5144779e 100644
--- a/sql/item_windowfunc.cc
+++ b/sql/item_windowfunc.cc
@@ -174,7 +174,8 @@ 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]->cmp_type();
+ Item *src_item= window_spec->order_list->first->item[0];
+ Item_result rtype= src_item->cmp_type();
// TODO (varun) : support date type in percentile_cont function
if (rtype != REAL_RESULT && rtype != INT_RESULT &&
rtype != DECIMAL_RESULT && rtype != TIME_RESULT)
@@ -182,7 +183,14 @@ bool Item_window_func::check_result_type_of_order_item()
my_error(ER_WRONG_TYPE_FOR_PERCENTILE_FUNC, MYF(0), window_func()->func_name());
return TRUE;
}
- setting_handler_for_percentile_functions(rtype);
+ if (window_func()->sum_func() == Item_sum::PERCENTILE_DISC_FUNC)
+ {
+ 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;
}
diff --git a/sql/item_windowfunc.h b/sql/item_windowfunc.h
index 37376501d1f..1432643dfc8 100644
--- a/sql/item_windowfunc.h
+++ b/sql/item_windowfunc.h
@@ -1097,17 +1097,6 @@ public:
}
}
- void setting_handler_for_percentile_functions(Item_result rtype) const
- {
- switch (window_func()->sum_func()){
- case Item_sum::PERCENTILE_DISC_FUNC:
- ((Item_sum_percentile_disc* ) window_func())->set_handler_by_cmp_type(rtype);
- break;
- default:
- return;
- }
- }
-
bool check_result_type_of_order_item();
diff --git a/sql/sql_type.h b/sql/sql_type.h
index 3ef210efecf..a7915ddc463 100644
--- a/sql/sql_type.h
+++ b/sql/sql_type.h
@@ -3506,10 +3506,6 @@ public:
{
return (m_type_handler= Type_handler::get_handler_by_result_type(type));
}
- const Type_handler *set_handler_by_cmp_type(Item_result type)
- {
- return (m_type_handler= Type_handler::get_handler_by_cmp_type(type));
- }
const Type_handler *set_handler_by_result_type(Item_result type,
uint max_octet_length,
CHARSET_INFO *cs)