Skip to content

Commit 6ad9ac2

Browse files
committed
Encapsulate use of List<Cached_item> in a Group_bound_tracker.
1 parent c7a60de commit 6ad9ac2

File tree

3 files changed

+9
-17
lines changed

3 files changed

+9
-17
lines changed

sql/item_windowfunc.cc

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,7 @@ void Item_window_func::split_sum_func(THD *thd, Ref_ptr_array ref_pointer_array,
164164

165165
void Item_window_func::setup_partition_border_check(THD *thd)
166166
{
167-
for (ORDER *curr= window_spec->partition_list->first; curr; curr=curr->next)
168-
{
169-
//curr->item_ptr->fix_fields(thd, curr->item);
170-
Cached_item *tmp= new_Cached_item(thd, curr->item[0], TRUE);
171-
partition_fields.push_back(tmp);
172-
}
167+
partition_tracker.init(thd, window_spec->partition_list);
173168
window_func()->setup_window_func(thd, window_spec);
174169
}
175170

@@ -208,16 +203,14 @@ bool Item_sum_rank::add()
208203
return false;
209204
}
210205

211-
int Item_window_func::check_partition_bound()
206+
bool Item_window_func::check_if_partition_changed()
212207
{
213-
return test_if_group_changed(partition_fields);
208+
return partition_tracker.check_if_next_group();
214209
}
215210

216211
void Item_window_func::advance_window()
217212
{
218-
int changed= check_partition_bound();
219-
220-
if (changed > -1)
213+
if (check_if_partition_changed())
221214
{
222215
/* Next partition */
223216
window_func()->clear();

sql/item_windowfunc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ class Item_window_func : public Item_func_or_sum
485485
advance_window() uses this to tell when we've left one partition and
486486
entered another
487487
*/
488-
List<Cached_item> partition_fields;
488+
Group_bound_tracker partition_tracker;
489489
public:
490490
Item_window_func(THD *thd, Item_sum *win_func, LEX_STRING *win_name)
491491
: Item_func_or_sum(thd, (Item *) win_func),
@@ -537,7 +537,7 @@ class Item_window_func : public Item_func_or_sum
537537
void setup_partition_border_check(THD *thd);
538538

539539
void advance_window();
540-
int check_partition_bound();
540+
bool check_if_partition_changed();
541541

542542
enum_field_types field_type() const
543543
{

sql/sql_window.cc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,8 +1281,8 @@ bool compute_window_func_with_frames(Item_window_func *item_win,
12811281
{
12821282
break; /* End of file */
12831283
}
1284-
bool partition_changed= (item_win->check_partition_bound() > -1)? true:
1285-
false;
1284+
bool partition_changed= item_win->check_if_partition_changed();
1285+
12861286
tbl->file->position(tbl->record[0]);
12871287
memcpy(rowid_buf, tbl->file->ref, tbl->file->ref_length);
12881288

@@ -1382,8 +1382,7 @@ bool compute_two_pass_window_functions(Item_window_func *item_win,
13821382
done = true;
13831383
}
13841384

1385-
bool partition_changed= (done || item_win->check_partition_bound() > -1) ?
1386-
true : false;
1385+
bool partition_changed= done || item_win->check_if_partition_changed();
13871386
// The first time we always have a partition changed. Ignore it.
13881387
if (first_row)
13891388
{

0 commit comments

Comments
 (0)