Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CTE query execute failed:Recursive Common Table Expression '' can contain neither aggregation nor window functions in recursive query block #47603

Closed
snowballbear opened this issue Oct 13, 2023 · 5 comments · Fixed by #48188
Assignees
Labels
affects-6.5 affects-7.1 affects-7.5 found/gs found by gs may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug. type/regression

Comments

@snowballbear
Copy link

Bug Report

Please answer these questions before submitting your issue. Thanks!

The results of cte query execution are different in v6.1.6 and v6.5.2 .

1. Minimal reproduce step (Required)

create table a (id int);
create table b (id int);
create table temp (lvl int);
with a as (select 8 as id from dual),
maxa as (select max(id) as max_id from a),
b as (
with recursive temp as (
select 1 as lvl from dual
union all
select lvl+1 from temp, maxa where lvl < max_id
)
select * from temp
)
select * from b;

2. What did you expect to see? (Required)

v6.1.6
mysql> with a as (select 8 as id from dual),
-> maxa as (select max(id) as max_id from a),
-> b as (
-> with recursive temp as (
-> select 1 as lvl from dual
-> union all
-> select lvl+1 from temp, maxa where lvl < max_id
-> )
-> select * from temp
-> )
-> select * from b;
+------+
| lvl |
+------+
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 6 |
| 7 |
| 8 |
+------+
8 rows in set (0.01 sec)

3. What did you see instead (Required)

v6.5.2
mysql> with a as (select 8 as id from dual),
-> maxa as (select max(id) as max_id from a),
-> b as (
-> with recursive temp as (
-> select 1 as lvl from dual
-> union all
-> select lvl+1 from temp, maxa where lvl < max_id
-> )
-> select * from temp
-> )
-> select * from b;
ERROR 3575 (HY000): Recursive Common Table Expression '' can contain neither aggregation nor window functions in recursive query block

4. What is your TiDB version? (Required)

v6.5.2

@snowballbear snowballbear added the type/bug The issue is confirmed as a bug. label Oct 13, 2023
@snowballbear
Copy link
Author

/found gs

@ti-chi-bot ti-chi-bot bot added the found/gs found by gs label Oct 13, 2023
@ti-chi-bot ti-chi-bot bot added may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 may-affects-7.1 labels Oct 16, 2023
@jebter jebter added the sig/sql-infra SIG: SQL Infra label Oct 25, 2023
@YangKeao YangKeao self-assigned this Nov 8, 2023
@YangKeao
Copy link
Member

YangKeao commented Nov 8, 2023

Bisect shows this issue is caused by #37800 🤔 .

@kennedy8312
Copy link

/type regression

@kennedy8312
Copy link

Regression Analysis
The issue didn't show up in v6.3.0 but started to show up in v6.4.0.

@kennedy8312
Copy link

Regression Analysis
PR caused this regression: #37800

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment