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

Unreasonable behavior when use CTE in view #25235

Open
guo-shaoge opened this issue Jun 8, 2021 · 0 comments
Open

Unreasonable behavior when use CTE in view #25235

guo-shaoge opened this issue Jun 8, 2021 · 0 comments
Labels
severity/moderate sig/execution SIG execution type/bug The issue is confirmed as a bug.

Comments

@guo-shaoge
Copy link
Collaborator

guo-shaoge commented Jun 8, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

drop table if exists t1;
drop view if exists vv;
create table t1(c1 int primary key);
insert into t1 values(1), (2), (3);
create view vv as with recursive cte1(c1) as (select c1 from t1 where c1 = 2 union select c1 + 1 c1 from cte1 where c1 < 3) select * from cte1;
desc vv;

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

MySQL:

mysql> desc vv;
+-------+------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------+------+-----+---------+-------+
| c1    | int  | YES  |     | NULL    |       |
+-------+------+------+-----+---------+-------+
1 row in set (0.11 sec)

3. What did you see instead (Required)

TiDB: It's unreasonable because c1 is NULLABLE and Primary key.

mysql>     desc vv;
+-------+---------+------+------+---------+-------+
| Field | Type    | Null | Key  | Default | Extra |
+-------+---------+------+------+---------+-------+
| c1    | int(11) | YES  | PRI  | NULL    |       |
+-------+---------+------+------+---------+-------+
1 row in set (0.01 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 Jun 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/moderate sig/execution SIG execution type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

2 participants