1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Merge 10.3 into 10.4

This commit is contained in:
Marko Mäkelä
2020-07-15 10:17:15 +03:00
39 changed files with 467 additions and 141 deletions

View File

@ -24274,10 +24274,13 @@ int setup_order(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables,
List<Item> &fields, List<Item> &all_fields, ORDER *order,
bool from_window_spec)
{
SELECT_LEX *select = thd->lex->current_select;
enum_parsing_place context_analysis_place=
thd->lex->current_select->context_analysis_place;
thd->where="order clause";
for (; order; order=order->next)
const bool for_union= select->master_unit()->is_unit_op() &&
select == select->master_unit()->fake_select_lex;
for (uint number = 1; order; order=order->next, number++)
{
if (find_order_in_list(thd, ref_pointer_array, tables, order, fields,
all_fields, false, true, from_window_spec))
@ -24288,8 +24291,22 @@ int setup_order(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables,
my_error(ER_WINDOW_FUNCTION_IN_WINDOW_SPEC, MYF(0));
return 1;
}
if (from_window_spec && (*order->item)->with_sum_func() &&
(*order->item)->type() != Item::SUM_FUNC_ITEM)
if (!(*order->item)->with_sum_func())
continue;
/*
UNION queries cannot be used with an aggregate function in
an ORDER BY clause
*/
if (for_union)
{
my_error(ER_AGGREGATE_ORDER_FOR_UNION, MYF(0), number);
return 1;
}
if (from_window_spec && (*order->item)->type() != Item::SUM_FUNC_ITEM)
(*order->item)->split_sum_func(thd, ref_pointer_array,
all_fields, SPLIT_SUM_SELECT);
}