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 doesn't handle apply properly #31255

Closed
guo-shaoge opened this issue Jan 3, 2022 · 2 comments · Fixed by #31256
Closed

CTE doesn't handle apply properly #31255

guo-shaoge opened this issue Jan 3, 2022 · 2 comments · Fixed by #31256
Assignees
Labels
affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects the 5.4.x(LTS) versions. severity/major type/bug The issue is confirmed as a bug.

Comments

@guo-shaoge
Copy link
Collaborator

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

drop table if exists t1, t2;
create table t1(c1 int, c2 int);
insert into t1 values(2, 1);
insert into t1 values(2, 2);
create table t2(c1 int, c2 int);
insert into t2 values(1, 1);
insert into t2 values(3, 2);
select * from t1 where c1 > all(with cte1 as (select c1 from t2 where t2.c2 = t1.c2) select c1 from cte1);

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

mysql>     select * from t1 where c1 > all(with cte1 as (select c1 from t2 where t2.c2 = t1.c2) select c1 from cte1);
+------+------+
| c1   | c2   |
+------+------+
|    2 |    1 |
+------+------+

3. What did you see instead (Required)

mysql>     select * from t1 where c1 > all(with cte1 as (select c1 from t2 where t2.c2 = t1.c2) select c1 from cte1);
+------+------+
| c1   | c2   |
+------+------+
|    2 |    1 |
|    2 |    2 |
+------+------+
2 rows in set (0.00 sec)

4. What is your TiDB version? (Required)

master

@guo-shaoge guo-shaoge added the type/bug The issue is confirmed as a bug. label Jan 3, 2022
@guo-shaoge guo-shaoge added affects-5.4 This bug affects the 5.4.x(LTS) versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. labels Jan 3, 2022
@guo-shaoge guo-shaoge self-assigned this Jan 3, 2022
@wjhuang2016
Copy link
Member

It's a corner case and only happens when CTE is on the inner side.

@github-actions
Copy link

github-actions bot commented Jan 6, 2022

Please check whether the issue should be labeled with 'affects-x.y' or 'fixes-x.y.z', and then remove 'needs-more-info' label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects the 5.4.x(LTS) versions. severity/major type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants