From 942a9791b2231273ba20649a658c856641268fae Mon Sep 17 00:00:00 2001 From: Varun Gupta Date: Mon, 14 Dec 2020 14:34:14 +0530 Subject: MDEV-15208: server crashed, when using ORDER BY with window function and UNION SELECTs inside a UNION can have window function but not the global ORDER BY clause of the UNION. --- sql/sql_select.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sql/sql_select.cc') diff --git a/sql/sql_select.cc b/sql/sql_select.cc index db8a63eeb48..a3e8b453897 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -22796,7 +22796,9 @@ int setup_order(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables, an ORDER BY clause */ - if (for_union && (*order->item)->with_sum_func) + 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; -- cgit v1.2.1