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

planner: don't reset optFlag when build DataSource from View #15546

Closed
francis0407 opened this issue Mar 21, 2020 · 1 comment · Fixed by #15547
Closed

planner: don't reset optFlag when build DataSource from View #15546

francis0407 opened this issue Mar 21, 2020 · 1 comment · Fixed by #15547
Assignees
Labels
severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@francis0407
Copy link
Member

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. What did you do?

mysql> create table pt (a int primary key, b int)
 partition by range (a)
 (partition p0 values less than(10), 
partition p1 values less than(20), 
partition p2 values less than(30));
Query OK, 0 rows affected (0.04 sec)

mysql> insert into pt values(1, 1), (11, 11), (21, 21);

mysql> select * from t;
+------+------+
| a    | b    |
+------+------+
|    1 |    1 |
+------+------+
1 row in set (0.00 sec)
Query OK, 3 rows affected (0.01 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql> create view vt (a, b) as select a, b from t;
Query OK, 0 rows affected (0.00 sec)
mysql> select * from pt, t where pt.a < 10 and pt.b = t.b;
+---+------+------+------+
| a | b    | a    | b    |
+---+------+------+------+
| 1 |    1 |    1 |    1 |
+---+------+------+------+
1 row in set (0.01 sec)

mysql> select * from pt, vt where pt.a < 10 and pt.b = vt.b;
Empty set (0.00 sec)

2. What did you expect to see?

The two queries above should have the same result 1, 1, 1, 1.

3. What did you see instead?

When we use the view vt, the result set is empty.

4. What version of TiDB are you using? (tidb-server -V or run select tidb_version(); on TiDB)

4.0-beta

@francis0407 francis0407 added type/bug The issue is confirmed as a bug. sig/planner SIG: Planner labels Mar 21, 2020
@francis0407 francis0407 changed the title planner: don't reset optFlag when buildDataSource from View planner: don't reset optFlag when build DataSource from View Mar 21, 2020
@francis0407
Copy link
Member Author

The root cause is when we build DataSource from a View, we reset the optFlag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants