-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
subquery NULL compatibility #3773
Comments
another case: drop table if exists subq;
drop table if exists t;
create table subq(a bigint);
create table t(a bigint, b bigint);
insert into subq (a) values(1), (2), (3), (null);
insert into t (a, b) values (null, 1), (2, null); select a in (select * from subq) from t;
select b in (select * from subq) from t;
select null in (select * from subq) from t;
select 1 in (select * from subq) from t;
select 6 in (select * from subq) from t; |
TiDB > select a in (select * from subq) from t;
+---------------------------+
| a in (select * from subq) |
+---------------------------+
| NULL |
| 1 |
+---------------------------+
2 rows in set (0.00 sec) this behaves the same as MySQL TiDB > select null in (select * from subq) from t;
+------------------------------+
| null in (select * from subq) |
+------------------------------+
| 0 |
| 0 |
+------------------------------+
2 rows in set (0.00 sec)
TiDB > select 6 in (select * from subq) from t;
+---------------------------+
| 6 in (select * from subq) |
+---------------------------+
| 0 |
| 0 |
+---------------------------+
2 rows in set (0.00 sec) in MySQL, the above two sql returns two
the TiDB > explain select null in (select * from subq) from t;
+----------------+----------------+------+-------------------------------------------------+
| id | parents | task | operator info |
+----------------+----------------+------+-------------------------------------------------+
| TableScan_9 | | cop | table:t, range:(-inf,+inf), keep order:false |
| TableReader_10 | HashSemiJoin_8 | root | data:TableScan_9 |
| TableScan_11 | | cop | table:subq, range:(-inf,+inf), keep order:false |
| TableReader_12 | Selection_7 | root | data:TableScan_11 |
| Selection_7 | HashSemiJoin_8 | root | eq(null, cast(test.subq.a)) |
| HashSemiJoin_8 | | root | right:Selection_7, aux |
+----------------+----------------+------+-------------------------------------------------+
6 rows in set (0.00 sec) TiDB > explain select 6 in (select * from subq) from t;
+----------------+----------------+------+-------------------------------------------------+
| id | parents | task | operator info |
+----------------+----------------+------+-------------------------------------------------+
| TableScan_8 | | cop | table:t, range:(-inf,+inf), keep order:false |
| TableReader_9 | HashSemiJoin_7 | root | data:TableScan_8 |
| TableScan_10 | Selection_11 | cop | table:subq, range:(-inf,+inf), keep order:false |
| Selection_11 | | cop | eq(6, test.subq.a) |
| TableReader_12 | HashSemiJoin_7 | root | data:Selection_11 |
| HashSemiJoin_7 | | root | right:TableReader_12, aux |
+----------------+----------------+------+-------------------------------------------------+
6 rows in set (0.01 sec) to fix this issue, we have to:
|
Confirming that this can still be reproduced:
|
No table required, the easiest test-case for this is:
TiDB returns a bool (FALSE) versus NULL in MySQL. |
An example to show how this could manifest into bugs: mysql> SELECT NOT NULL IN (SELECT NULL);
+---------------------------+
| NOT NULL IN (SELECT NULL) |
+---------------------------+
| 1 |
+---------------------------+
1 row in set (0.00 sec) This should return |
Please edit this comment or add a new comment to complete the following informationNot a bug
Duplicate bug
BugNote: Make Sure that 'component', and 'severity' labels are added 1. Root Cause Analysis (RCA) (optional)2. Symptom (optional)3. All Trigger Conditions (optional)4. Workaround (optional)5. Affected versions6. Fixed versionsv5.0.0-rc |
( AffectedVersions ) fields are empty. |
Description
MySQL:
TiDB:
SIG slack channel
#sig-exec
Score
Mentor
The text was updated successfully, but these errors were encountered: