Commit 31f1541f authored by Varun Gupta's avatar Varun Gupta

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

Setting handler to have the return type as that of the element by which we are ordering the partition
parent cc046fa9
......@@ -5386,7 +5386,7 @@ class Cached_item_decimal :public Cached_item_item
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;
......
......@@ -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)
......
......@@ -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 @@ class Item_sum_percentile_disc : public Item_sum_cume_dist
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 @@ class Item_sum_percentile_disc : public Item_sum_cume_dist
}
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()
{
......
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment