Skip to content

Commit 044060f

Browse files
author
Chaithra Gopalareddy
committed
Bug #20730220 : BACKPORT BUG#19880368 TO 5.1
Backport from mysql-5.5 to mysql-5.1 Bug#19880368 : GROUP_CONCAT CRASHES AFTER DUMP_LEAF_KEY Problem: find_order_by_list does not update the address of order_item correctly after resolving. Solution: Change the ref_by address for a order_by field if its SUM_FUNC_ITEM to the address of the field present in all_fields.
1 parent a2cd622 commit 044060f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

sql/sql_select.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14937,6 +14937,17 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables,
1493714937
uint el= all_fields.elements;
1493814938
all_fields.push_front(order_item); /* Add new field to field list. */
1493914939
ref_pointer_array[el]= order_item;
14940+
/*
14941+
If the order_item is a SUM_FUNC_ITEM, when fix_fields is called
14942+
ref_by is set to order->item which is the address of order_item.
14943+
But this needs to be address of order_item in the all_fields list.
14944+
As a result, when it gets replaced with Item_aggregate_ref
14945+
object in Item::split_sum_func2, we will be able to retrieve the
14946+
newly created object.
14947+
*/
14948+
if (order_item->type() == Item::SUM_FUNC_ITEM)
14949+
((Item_sum *)order_item)->ref_by= all_fields.head_ref();
14950+
1494014951
order->item= ref_pointer_array + el;
1494114952
return FALSE;
1494214953
}

0 commit comments

Comments
 (0)