diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2022-02-25 16:24:13 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2022-02-25 16:24:13 +0200 |
commit | 32d741b5b0087d6322cee0e8a7d34aa694e30d69 (patch) | |
tree | 008cc440d23e34eb4a589aec996682cc58c3fd50 /sql/sql_select.cc | |
parent | a23414dd32c6b72d492642fdbd5d3a13834e6f23 (diff) | |
parent | 3d88f9f34c1223c59272d5086dcd2b4b2cfc167b (diff) | |
download | mariadb-git-32d741b5b0087d6322cee0e8a7d34aa694e30d69.tar.gz |
Merge 10.7 into 10.8
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r-- | sql/sql_select.cc | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index cf5b73fecfc..c044656e916 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -25063,20 +25063,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); |