summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorChaithra Gopalareddy <chaithra.gopalareddy@oracle.com>2015-02-20 11:04:43 +0530
committerChaithra Gopalareddy <chaithra.gopalareddy@oracle.com>2015-02-20 11:04:43 +0530
commit674367afd56f93bac4fddde6c6e422c17591d0d2 (patch)
tree182e82a71b9ee30790a1ecb2db2ea960eee5455b /sql
parent1a5b8122b615d07223ed4855ae35c511bcedd5fc (diff)
downloadmariadb-git-674367afd56f93bac4fddde6c6e422c17591d0d2.tar.gz
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.
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_select.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index e112aa9ae5e..7b49f378223 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -15158,6 +15158,17 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables,
uint el= all_fields.elements;
all_fields.push_front(order_item); /* Add new field to field list. */
ref_pointer_array[el]= order_item;
+ /*
+ If the order_item is a SUM_FUNC_ITEM, when fix_fields is called
+ ref_by is set to order->item which is the address of order_item.
+ But this needs to be address of order_item in the all_fields list.
+ As a result, when it gets replaced with Item_aggregate_ref
+ object in Item::split_sum_func2, we will be able to retrieve the
+ newly created object.
+ */
+ if (order_item->type() == Item::SUM_FUNC_ITEM)
+ ((Item_sum *)order_item)->ref_by= all_fields.head_ref();
+
order->item= ref_pointer_array + el;
return FALSE;
}