Commit 6ad9ac21 authored by Sergei Petrunia's avatar Sergei Petrunia

Encapsulate use of List<Cached_item> in a Group_bound_tracker.

parent c7a60de7
...@@ -164,12 +164,7 @@ void Item_window_func::split_sum_func(THD *thd, Ref_ptr_array ref_pointer_array, ...@@ -164,12 +164,7 @@ void Item_window_func::split_sum_func(THD *thd, Ref_ptr_array ref_pointer_array,
void Item_window_func::setup_partition_border_check(THD *thd) void Item_window_func::setup_partition_border_check(THD *thd)
{ {
for (ORDER *curr= window_spec->partition_list->first; curr; curr=curr->next) partition_tracker.init(thd, window_spec->partition_list);
{
//curr->item_ptr->fix_fields(thd, curr->item);
Cached_item *tmp= new_Cached_item(thd, curr->item[0], TRUE);
partition_fields.push_back(tmp);
}
window_func()->setup_window_func(thd, window_spec); window_func()->setup_window_func(thd, window_spec);
} }
...@@ -208,16 +203,14 @@ bool Item_sum_rank::add() ...@@ -208,16 +203,14 @@ bool Item_sum_rank::add()
return false; return false;
} }
int Item_window_func::check_partition_bound() bool Item_window_func::check_if_partition_changed()
{ {
return test_if_group_changed(partition_fields); return partition_tracker.check_if_next_group();
} }
void Item_window_func::advance_window() void Item_window_func::advance_window()
{ {
int changed= check_partition_bound(); if (check_if_partition_changed())
if (changed > -1)
{ {
/* Next partition */ /* Next partition */
window_func()->clear(); window_func()->clear();
......
...@@ -485,7 +485,7 @@ class Item_window_func : public Item_func_or_sum ...@@ -485,7 +485,7 @@ class Item_window_func : public Item_func_or_sum
advance_window() uses this to tell when we've left one partition and advance_window() uses this to tell when we've left one partition and
entered another entered another
*/ */
List<Cached_item> partition_fields; Group_bound_tracker partition_tracker;
public: public:
Item_window_func(THD *thd, Item_sum *win_func, LEX_STRING *win_name) Item_window_func(THD *thd, Item_sum *win_func, LEX_STRING *win_name)
: Item_func_or_sum(thd, (Item *) win_func), : Item_func_or_sum(thd, (Item *) win_func),
...@@ -537,7 +537,7 @@ class Item_window_func : public Item_func_or_sum ...@@ -537,7 +537,7 @@ class Item_window_func : public Item_func_or_sum
void setup_partition_border_check(THD *thd); void setup_partition_border_check(THD *thd);
void advance_window(); void advance_window();
int check_partition_bound(); bool check_if_partition_changed();
enum_field_types field_type() const enum_field_types field_type() const
{ {
......
...@@ -1281,8 +1281,8 @@ bool compute_window_func_with_frames(Item_window_func *item_win, ...@@ -1281,8 +1281,8 @@ bool compute_window_func_with_frames(Item_window_func *item_win,
{ {
break; /* End of file */ break; /* End of file */
} }
bool partition_changed= (item_win->check_partition_bound() > -1)? true: bool partition_changed= item_win->check_if_partition_changed();
false;
tbl->file->position(tbl->record[0]); tbl->file->position(tbl->record[0]);
memcpy(rowid_buf, tbl->file->ref, tbl->file->ref_length); memcpy(rowid_buf, tbl->file->ref, tbl->file->ref_length);
...@@ -1382,8 +1382,7 @@ bool compute_two_pass_window_functions(Item_window_func *item_win, ...@@ -1382,8 +1382,7 @@ bool compute_two_pass_window_functions(Item_window_func *item_win,
done = true; done = true;
} }
bool partition_changed= (done || item_win->check_partition_bound() > -1) ? bool partition_changed= done || item_win->check_if_partition_changed();
true : false;
// The first time we always have a partition changed. Ignore it. // The first time we always have a partition changed. Ignore it.
if (first_row) if (first_row)
{ {
......
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