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

Wrong result when we compare field with zero value in subquery #21674

Closed
Reminiscent opened this issue Dec 11, 2020 · 3 comments · Fixed by #21699
Closed

Wrong result when we compare field with zero value in subquery #21674

Reminiscent opened this issue Dec 11, 2020 · 3 comments · Fixed by #21699
Assignees
Labels
severity/critical sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@Reminiscent
Copy link
Contributor

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);
CREATE TABLE t2(c1 int, c2 int);
INSERT INTO t1(`c1`, `c2`) VALUES(0, 0);
INSERT INTO t2(`c1`, `c2`) VALUES(0, 0);
SELECT * FROM t2 WHERE (SELECT c1 FROM t2 LIMIT 1) = ANY (SELECT c1 FROM t1);

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

mysql> DROP TABLE IF EXISTS t1, t2;
Query OK, 0 rows affected (0.01 sec)

mysql> CREATE TABLE t1(c1 int, c2 int);
Query OK, 0 rows affected (0.01 sec)

mysql> CREATE TABLE t2(c1 int, c2 int);
Query OK, 0 rows affected (0.02 sec)

mysql> INSERT INTO t1(`c1`, `c2`) VALUES(0, 0);
Query OK, 1 row affected (0.01 sec)

mysql> INSERT INTO t2(`c1`, `c2`) VALUES(0, 0);
Query OK, 1 row affected (0.00 sec)

mysql> SELECT * FROM t2 WHERE (SELECT c1 FROM t2 LIMIT 1) = ANY (SELECT c1 FROM t1);
+------+------+
| c1   | c2   |
+------+------+
|    0 |    0 |
+------+------+
1 row in set (0.01 sec)

mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.20    |
+-----------+
1 row in set (0.00 sec)

3. What did you see instead (Required)

mysql> DROP TABLE IF EXISTS t1, t2;
Query OK, 0 rows affected (0.04 sec)

mysql> CREATE TABLE t1(c1 int, c2 int);
Query OK, 0 rows affected (0.01 sec)

mysql> CREATE TABLE t2(c1 int, c2 int);
Query OK, 0 rows affected (0.01 sec)

mysql> INSERT INTO t1(`c1`, `c2`) VALUES(0, 0);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO t2(`c1`, `c2`) VALUES(0, 0);
Query OK, 1 row affected (0.00 sec)

mysql> SELECT * FROM t2 WHERE (SELECT c1 FROM t2 LIMIT 1) = ANY (SELECT c1 FROM t1);
Empty set (0.01 sec)

4. What is your TiDB version? (Required)

Latest master 39d8fcc71b6d83a96defcbeafaf2c076583a8328

@Reminiscent Reminiscent added the type/bug The issue is confirmed as a bug. label Dec 11, 2020
@Reminiscent
Copy link
Contributor Author

/label sig/planner

@ti-srebot ti-srebot added the sig/planner SIG: Planner label Dec 11, 2020
@Reminiscent
Copy link
Contributor Author

/assign

@ti-srebot
Copy link
Contributor

Please edit this comment or add a new comment to complete the following information

Not a bug

  1. Remove the 'type/bug' label
  2. Add notes to indicate why it is not a bug

Duplicate bug

  1. Add the 'type/duplicate' label
  2. Add the link to the original bug

Bug

Note: Make Sure that 'component', and 'severity' labels are added
Example for how to fill out the template: #20100

1. Root Cause Analysis (RCA) (optional)

2. Symptom (optional)

3. All Trigger Conditions (optional)

4. Workaround (optional)

5. Affected versions

6. Fixed versions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/critical 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.

3 participants