Skip to content

Commit 54b81ac

Browse files
committed
Window functions fail with --ps-protocol
When running with --ps protocol, window functions cleanup method may be called twice. Enforce proper cleanup by setting pointers to NULL after deletion. This prevents double deletion on second cleanup.
1 parent ec59220 commit 54b81ac

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

sql/item_windowfunc.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,11 @@ class Item_sum_rank: public Item_sum_int
198198
void cleanup()
199199
{
200200
if (peer_tracker)
201+
{
201202
peer_tracker->cleanup();
202-
delete peer_tracker;
203+
delete peer_tracker;
204+
peer_tracker= NULL;
205+
}
203206
Item_sum_int::cleanup();
204207
}
205208
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
@@ -268,6 +271,7 @@ class Item_sum_dense_rank: public Item_sum_int
268271
{
269272
peer_tracker->cleanup();
270273
delete peer_tracker;
274+
peer_tracker= NULL;
271275
}
272276
Item_sum_int::cleanup();
273277
}
@@ -379,6 +383,7 @@ class Item_sum_percent_rank: public Item_sum_window_with_row_count
379383
{
380384
peer_tracker->cleanup();
381385
delete peer_tracker;
386+
peer_tracker= NULL;
382387
}
383388
Item_sum_num::cleanup();
384389
}

0 commit comments

Comments
 (0)