Setting handler to have the return type as that of the element by which we are ordering the partition

This commit is contained in:
Varun Gupta 2017-06-26 03:53:27 +05:30
parent cc046fa92c
commit 31f1541f1e
4 changed files with 18 additions and 5 deletions

View file

@ -5386,7 +5386,7 @@ public:
Cached_item_decimal(Item *item_par);
bool cmp(void);
int cmp_read_only();
my_decimal get_value(){ return value;};
my_decimal *get_value(){ return &value;};
void clear()
{
null_value= false;

View file

@ -210,6 +210,11 @@ void Item_sum_percentile_disc::setup_window_func(THD *thd, Window_spec *window_s
setup_percentile_func(thd, window_spec->order_list);
}
void Item_sum_percentile_disc::set_type_handler(Window_spec *window_spec)
{
type_handler()->get_handler_by_cmp_type(window_spec->order_list->first->item[0]->result_type());
}
bool Item_sum_dense_rank::add()
{
if (peer_tracker->check_if_next_group() || first_add)

View file

@ -701,11 +701,13 @@ class Item_sum_ntile : public Item_sum_window_with_row_count
ulong current_row_count_;
};
class Item_sum_percentile_disc : public Item_sum_cume_dist
class Item_sum_percentile_disc : public Item_sum_cume_dist,
public Type_handler_hybrid_field_type
{
public:
Item_sum_percentile_disc(THD *thd, Item* arg) : Item_sum_cume_dist(thd, arg),
value(NULL), val_calculated(FALSE) {}
Type_handler_hybrid_field_type(&type_handler_longlong),
value(NULL), val_calculated(FALSE) {}
double val_real()
{
@ -715,7 +717,7 @@ public:
return 0;
}
null_value= false;
return ((Cached_item_int*) value)->get_value();
return ((Cached_item_real*) value)->get_value();
}
longlong val_int()
@ -769,7 +771,9 @@ public:
}
void update_field() {}
const Type_handler *type_handler() const { return &type_handler_double; }
void set_type_handler(Window_spec *window_spec);
const Type_handler *type_handler() const
{return Type_handler_hybrid_field_type::type_handler();}
void fix_length_and_dec()
{

View file

@ -319,6 +319,10 @@ setup_windows(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables,
while ((win_func_item= li++))
{
win_func_item->update_used_tables();
if (win_func_item->only_single_element_order_list())
{
((Item_sum_percentile_disc*)win_func_item)->set_type_handler(win_func_item->window_spec);
}
}
DBUG_RETURN(0);