summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2022-02-25 13:27:41 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2022-02-25 13:27:41 +0200
commitb791b942e1c04113c65cb7d3eaaf3cae8963efee (patch)
treec38449686a4dc894ef9d421a722e2a3f120879cf /sql/sql_select.cc
parentf42d6234bdc5838f140f6a4541acb17a96434ba6 (diff)
parentf5ff7d09c73b5527cb6e0540cd470db9d8a82108 (diff)
downloadmariadb-git-b791b942e1c04113c65cb7d3eaaf3cae8963efee.tar.gz
Merge 10.4 into 10.5
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r--sql/sql_select.cc12
1 files changed, 7 insertions, 5 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 47e23a8b48d..b20a2262610 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates.
- Copyright (c) 2009, 2021, MariaDB Corporation.
+ Copyright (c) 2009, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -24832,20 +24832,22 @@ int setup_order(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables,
return 1;
}
- if (!(*order->item)->with_sum_func())
- continue;
-
/*
UNION queries cannot be used with an aggregate function in
an ORDER BY clause
*/
- if (for_union)
+ if (for_union &&
+ ((*order->item)->with_sum_func() ||
+ (*order->item)->with_window_func))
{
my_error(ER_AGGREGATE_ORDER_FOR_UNION, MYF(0), number);
return 1;
}
+ if (!(*order->item)->with_sum_func())
+ continue;
+
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);