Commit 1d98333a authored by Igor Babaev's avatar Igor Babaev

MDEV-15894 Error, while using aggregated functions/window functions in anchor part

Usage of aggregate/window functions in non-recursive parts of recursive CTEs
is allowed. Error messages complaining about this were reported by mistake.
parent e34d3184
......@@ -3179,3 +3179,22 @@ p1 k2 p2 k1
10 10 10 10
DROP PROCEDURE getNums;
DROP TABLE t1;
#
# MDEV-15894: aggregate/winfow functions in non-recorsive part
#
create table t1(b int);
insert into t1 values(10),(20),(10);
with recursive qn as
(select max(b) as a from t1 union
select a from qn)
select * from qn;
a
20
with recursive qn as
(select rank() over (order by b) as a from t1 union
select a from qn)
select * from qn;
a
1
3
drop table t1;
......@@ -2190,3 +2190,22 @@ call getNums();
DROP PROCEDURE getNums;
DROP TABLE t1;
--echo #
--echo # MDEV-15894: aggregate/winfow functions in non-recorsive part
--echo #
create table t1(b int);
insert into t1 values(10),(20),(10);
with recursive qn as
(select max(b) as a from t1 union
select a from qn)
select * from qn;
with recursive qn as
(select rank() over (order by b) as a from t1 union
select a from qn)
select * from qn;
drop table t1;
......@@ -1173,7 +1173,7 @@ bool st_select_lex::check_unrestricted_recursive(bool only_standard_compliant)
/* Check conditions 3-4 for restricted specification*/
if (with_sum_func ||
if ((with_sum_func && !with_elem->is_anchor(this)) ||
(with_elem->contains_sq_with_recursive_reference()))
with_elem->get_owner()->add_unrestricted(
with_elem->get_mutually_recursive());
......
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