Skip to content

Commit

Permalink
Changes made according to the review given, mostly fixing coding styl…
Browse files Browse the repository at this point in the history
…e errors
  • Loading branch information
varunraiko committed Nov 1, 2017
1 parent 24e219b commit b5c104d
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 196 deletions.
111 changes: 0 additions & 111 deletions mysql-test/r/win_percentile_cont.result

This file was deleted.

55 changes: 0 additions & 55 deletions mysql-test/t/win_percentile_cont.test

This file was deleted.

3 changes: 0 additions & 3 deletions sql/item.h
Original file line number Diff line number Diff line change
Expand Up @@ -5341,7 +5341,6 @@ class Cached_item_real :public Cached_item_item
Cached_item_real(Item *item_par) :Cached_item_item(item_par),value(0.0) {}
bool cmp(void);
int cmp_read_only();
double get_value(){ return value;}
};

class Cached_item_int :public Cached_item_item
Expand All @@ -5351,7 +5350,6 @@ class Cached_item_int :public Cached_item_item
Cached_item_int(Item *item_par) :Cached_item_item(item_par),value(0) {}
bool cmp(void);
int cmp_read_only();
longlong get_value(){ return value;}
};


Expand All @@ -5362,7 +5360,6 @@ 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;};
};

class Cached_item_field :public Cached_item
Expand Down
18 changes: 10 additions & 8 deletions sql/item_windowfunc.h
Original file line number Diff line number Diff line change
Expand Up @@ -757,14 +757,14 @@ class Item_sum_percentile_disc : public Item_sum_cume_dist,

bool add()
{
Item *arg = get_arg(0);
Item *arg= get_arg(0);
if (arg->is_null())
return false;

if (first_call)
{
prev_value= arg->val_real();
if (prev_value >1 || prev_value < 0)
if (prev_value > 1 || prev_value < 0)
{
my_error(ER_ARGUMENT_OUT_OF_RANGE, MYF(0));
return true;
Expand All @@ -774,7 +774,7 @@ class Item_sum_percentile_disc : public Item_sum_cume_dist,

double arg_val= arg->val_real();

if (prev_value != arg_val)
if (prev_value != arg_val)
{
my_error(ER_ARGUMENT_NOT_CONSTANT, MYF(0));
return true;
Expand Down Expand Up @@ -821,14 +821,15 @@ class Item_sum_percentile_disc : public Item_sum_cume_dist,

void fix_length_and_dec()
{
decimals = 10; // TODO-cvicentiu find out how many decimals the standard
decimals = 5; // TODO-cvicentiu find out how many decimals the standard
// requires.
}

Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_sum_percentile_disc>(thd, mem_root, this); }
void setup_window_func(THD *thd, Window_spec *window_spec);
void setup_hybrid(THD *thd, Item *item);
bool fix_fields(THD *thd, Item **ref);

private:
Item_cache *value;
Expand Down Expand Up @@ -876,23 +877,23 @@ class Item_sum_percentile_cont : public Item_sum_cume_dist,

bool add()
{
Item *arg = get_arg(0);
Item *arg= get_arg(0);
if (arg->is_null())
return false;

if (first_call)
{
first_call= false;
prev_value= arg->val_real();
if (prev_value >1 || prev_value < 0)
if (prev_value > 1 || prev_value < 0)
{
my_error(ER_ARGUMENT_OUT_OF_RANGE, MYF(0));
return true;
}
}

double arg_val= arg->val_real();
if (prev_value != arg_val)
if (prev_value != arg_val)
{
my_error(ER_ARGUMENT_NOT_CONSTANT, MYF(0));
return true;
Expand Down Expand Up @@ -950,14 +951,15 @@ class Item_sum_percentile_cont : public Item_sum_cume_dist,

void fix_length_and_dec()
{
decimals = 10; // TODO-cvicentiu find out how many decimals the standard
decimals = 5; // TODO-cvicentiu find out how many decimals the standard
// requires.
}

Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_sum_percentile_cont>(thd, mem_root, this); }
void setup_window_func(THD *thd, Window_spec *window_spec);
void setup_hybrid(THD *thd, Item *item);
bool fix_fields(THD *thd, Item **ref);

private:
Item_cache *floor_value;
Expand Down
37 changes: 18 additions & 19 deletions sql/sql_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1743,7 +1743,17 @@ class Frame_unbounded_following_set_count : public Frame_unbounded_following
/* Walk to the end of the partition, find how many rows there are. */
while (!cursor.next())
num_rows_in_partition++;
set_win_funcs_row_count(num_rows_in_partition);
}

ha_rows get_curr_rownum() const
{
return cursor.get_rownum();
}

protected:
void set_win_funcs_row_count(ha_rows num_rows_in_partition)
{
List_iterator_fast<Item_sum> it(sum_functions);
Item_sum* item;
while ((item= it++))
Expand All @@ -1753,20 +1763,16 @@ class Frame_unbounded_following_set_count : public Frame_unbounded_following
item_with_row_count->set_row_count(num_rows_in_partition);
}
}

ha_rows get_curr_rownum() const
{
return cursor.get_rownum();
}
};

class Frame_unbounded_following_set_count_special: public Frame_unbounded_following_set_count
class Frame_unbounded_following_set_count_no_nulls:
public Frame_unbounded_following_set_count
{

public:
Frame_unbounded_following_set_count_special(THD *thd,
Frame_unbounded_following_set_count_no_nulls(THD *thd,
SQL_I_List<ORDER> *partition_list,
SQL_I_List<ORDER> *order_list, Item* arg) :
SQL_I_List<ORDER> *order_list) :
Frame_unbounded_following_set_count(thd,partition_list, order_list)
{
order_item= order_list->first->item[0];
Expand All @@ -1782,16 +1788,9 @@ class Frame_unbounded_following_set_count_special: public Frame_unbounded_follow
{
if (!order_item->is_null())
num_rows_in_partition++;
}while (!cursor.next());
} while (!cursor.next());

List_iterator_fast<Item_sum> it(sum_functions);
Item_sum* item;
while ((item= it++))
{
Item_sum_window_with_row_count* item_with_row_count =
static_cast<Item_sum_window_with_row_count *>(item);
item_with_row_count->set_row_count(num_rows_in_partition);
}
set_win_funcs_row_count(num_rows_in_partition);
}

ha_rows get_curr_rownum() const
Expand Down Expand Up @@ -2614,9 +2613,9 @@ void get_window_functions_required_cursors(
{
if (item_win_func->only_single_element_order_list())
{
fc= new Frame_unbounded_following_set_count_special(thd,
fc= new Frame_unbounded_following_set_count_no_nulls(thd,
item_win_func->window_spec->partition_list,
item_win_func->window_spec->order_list, item_win_func->window_func()->get_arg(0));
item_win_func->window_spec->order_list);
}
else
{
Expand Down

0 comments on commit b5c104d

Please sign in to comment.