Commit 8c34eab9 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-28094 Window function in expression in ORDER BY

call item->split_sum_func() in setup_order() just as
it's done in setup_fields()
parent bc9102eb
...@@ -93,3 +93,15 @@ pk a c sum(c) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 FO ...@@ -93,3 +93,15 @@ pk a c sum(c) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 FO
126 6 NULL NULL 126 6 NULL NULL
127 6 NULL NULL 127 6 NULL NULL
drop table t1; drop table t1;
#
# End of 10.2 tests
#
#
# MDEV-28094 Window function in expression in ORDER BY
#
SELECT EXISTS (SELECT 1 ORDER BY 1+sum(2) OVER ());
EXISTS (SELECT 1 ORDER BY 1+sum(2) OVER ())
1
#
# End of 10.4 tests
#
...@@ -45,3 +45,16 @@ select pk, a, c, sum(c) over (partition by a order by pk ROWS BETWEEN 1 PRECEDIN ...@@ -45,3 +45,16 @@ select pk, a, c, sum(c) over (partition by a order by pk ROWS BETWEEN 1 PRECEDIN
from t1; from t1;
drop table t1; drop table t1;
--echo #
--echo # End of 10.2 tests
--echo #
--echo #
--echo # MDEV-28094 Window function in expression in ORDER BY
--echo #
SELECT EXISTS (SELECT 1 ORDER BY 1+sum(2) OVER ());
--echo #
--echo # End of 10.4 tests
--echo #
...@@ -24546,8 +24546,8 @@ int setup_order(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables, ...@@ -24546,8 +24546,8 @@ int setup_order(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables,
return 1; return 1;
} }
if (from_window_spec && item->with_sum_func() && if ((from_window_spec && item->with_sum_func() &&
item->type() != Item::SUM_FUNC_ITEM) item->type() != Item::SUM_FUNC_ITEM) || item->with_window_func)
{ {
item->split_sum_func(thd, ref_pointer_array, item->split_sum_func(thd, ref_pointer_array,
all_fields, SPLIT_SUM_SELECT); all_fields, SPLIT_SUM_SELECT);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment