mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
Merge remote-tracking branch 'mysql/5.5' into 5.5
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2000, 2014 Oracle and/or its affiliates.
|
||||
/* Copyright (c) 2000, 2015 Oracle and/or its affiliates.
|
||||
Copyright (c) 2009, 2015 MariaDB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@@ -20309,18 +20309,33 @@ SORT_FIELD *make_unireg_sortorder(ORDER *order, uint *length,
|
||||
|
||||
for (;order;order=order->next,pos++)
|
||||
{
|
||||
Item *item= order->item[0]->real_item();
|
||||
Item *const item= order->item[0], *const real_item= item->real_item();
|
||||
pos->field= 0; pos->item= 0;
|
||||
if (item->type() == Item::FIELD_ITEM)
|
||||
pos->field= ((Item_field*) item)->field;
|
||||
else if (item->type() == Item::SUM_FUNC_ITEM && !item->const_item())
|
||||
pos->field= ((Item_sum*) item)->get_tmp_table_field();
|
||||
else if (item->type() == Item::COPY_STR_ITEM)
|
||||
{ // Blob patch
|
||||
pos->item= ((Item_copy*) item)->get_item();
|
||||
if (real_item->type() == Item::FIELD_ITEM)
|
||||
{
|
||||
// Could be a field, or Item_direct_view_ref wrapping a field
|
||||
DBUG_ASSERT(item->type() == Item::FIELD_ITEM ||
|
||||
(item->type() == Item::REF_ITEM &&
|
||||
static_cast<Item_ref*>(item)->ref_type() ==
|
||||
Item_ref::VIEW_REF));
|
||||
pos->field= static_cast<Item_field*>(real_item)->field;
|
||||
}
|
||||
else if (real_item->type() == Item::SUM_FUNC_ITEM &&
|
||||
!real_item->const_item())
|
||||
{
|
||||
// Aggregate, or Item_aggregate_ref
|
||||
DBUG_ASSERT(item->type() == Item::SUM_FUNC_ITEM ||
|
||||
(item->type() == Item::REF_ITEM &&
|
||||
static_cast<Item_ref*>(item)->ref_type() ==
|
||||
Item_ref::AGGREGATE_REF));
|
||||
pos->field= item->get_tmp_table_field();
|
||||
}
|
||||
else if (real_item->type() == Item::COPY_STR_ITEM)
|
||||
{ // Blob patch
|
||||
pos->item= static_cast<Item_copy*>(real_item)->get_item();
|
||||
}
|
||||
else
|
||||
pos->item= *order->item;
|
||||
pos->item= item;
|
||||
pos->reverse=! order->asc;
|
||||
}
|
||||
*length=count;
|
||||
@@ -20562,6 +20577,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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user