tidb icon indicating copy to clipboard operation
tidb copied to clipboard

CTE + Union return incorrect results

Open elsa0520 opened this issue 3 years ago • 0 comments

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

  1. query
with cte1 as (select 1), cte2 as (select 2) select * from cte1 union (with cte2 as (select 3) select * from cte2 union all select * from cte2);

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

+------+
| 1    |
+------+
|    3 |
|    1 |
+------+
2 rows in set (0.00 sec)

3. What did you see instead (Required)

+------+
| 1    |
+------+
|    2 |
|    1 |
+------+
2 rows in set (0.00 sec)

4. What is your TiDB version? (Required)

v6.2.0

elsa0520 avatar Sep 19 '22 06:09 elsa0520