-
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
Incorrect query result caused by LEFT/RIGHT JOIN #51361
Labels
affects-8.1
This bug affects the 8.1.x(LTS) versions.
may-affects-5.4
This bug maybe affects 5.4.x versions.
may-affects-6.1
may-affects-6.5
may-affects-7.1
may-affects-7.5
severity/major
sig/planner
SIG: Planner
type/bug
The issue is confirmed as a bug.
Comments
[16:14:44]TiDB root:test> SELECT * FROM (SELECT t0.c0, (TIMEDIFF('2003-07-13', '2007-06-25') AND true) IS TRUE AS flag FROM v0 LEFT JOIN t0 ON 1) AS t where flag = 1;
+------------+------+
| c0 | flag |
+------------+------+
| 1.4013e-45 | 1 |
+------------+------+
1 row in set
Time: 0.004s
[16:14:52]TiDB root:test> SELECT * FROM (SELECT t0.c0, (TIMEDIFF('2003-07-13', '2007-06-25') AND true) IS TRUE AS flag FROM v0 LEFT JOIN t0 ON 1) AS t ;
+--------+------+
| c0 | flag |
+--------+------+
| <null> | 1 |
+--------+------+
1 row in set
Time: 0.004s
[16:15:00]TiDB root:test> explain SELECT * FROM (SELECT t0.c0, (TIMEDIFF('2003-07-13', '2007-06-25') AND true) IS TRUE AS flag FROM v0 LEFT JOIN t0 ON 1) AS t where flag = 1;
+--------------------------+---------+-----------+---------------+---------------------------------------------------------------------------------------------------------------+
| id | estRows | task | access object | operator info |
+--------------------------+---------+-----------+---------------+---------------------------------------------------------------------------------------------------------------+
| Projection_12 | 2.56 | root | | test.t0.c0, istrue(and(istrue_with_null(cast(timediff(2003-07-13, 2007-06-25), double BINARY)), 1))->Column#5 |
| └─HashJoin_14 | 2.56 | root | | CARTESIAN left outer join |
| ├─Selection_15(Build) | 1.60 | root | | eq(istrue(and(istrue_with_null(cast(timediff("2003-07-13", "2007-06-25"), double BINARY)), 1)), 1) |
| │ └─TableReader_18 | 2.00 | root | | data:TableFullScan_17 |
| │ └─TableFullScan_17 | 2.00 | cop[tikv] | table:t0 | keep order:false |
| └─Selection_19(Probe) | 1.60 | root | | eq(istrue(and(istrue_with_null(cast(timediff("2003-07-13", "2007-06-25"), double BINARY)), 1)), 1) |
| └─TableReader_21 | 2.00 | root | | data:TableFullScan_20 |
| └─TableFullScan_20 | 2.00 | cop[tikv] | table:t0 | keep order:false |
+--------------------------+---------+-----------+---------------+---------------------------------------------------------------------------------------------------------------+
8 rows in set
Time: 0.004s
[16:15:10]TiDB root:test> explain SELECT * FROM (SELECT t0.c0, (TIMEDIFF('2003-07-13', '2007-06-25') AND true) IS TRUE AS flag FROM v0 LEFT JOIN t0 ON 1) AS t ;
+---------------------------+---------+-----------+---------------+---------------------------------------------------------------------------------------------------------------+
| id | estRows | task | access object | operator info |
+---------------------------+---------+-----------+---------------+---------------------------------------------------------------------------------------------------------------+
| Projection_8 | 4.00 | root | | test.t0.c0, istrue(and(istrue_with_null(cast(timediff(2003-07-13, 2007-06-25), double BINARY)), 1))->Column#5 |
| └─HashJoin_10 | 4.00 | root | | CARTESIAN left outer join |
| ├─Projection_11(Build) | 2.00 | root | | 1->Column#8 |
| │ └─TableReader_13 | 2.00 | root | | data:TableFullScan_12 |
| │ └─TableFullScan_12 | 2.00 | cop[tikv] | table:t0 | keep order:false |
| └─TableReader_15(Probe) | 2.00 | root | | data:TableFullScan_14 |
| └─TableFullScan_14 | 2.00 | cop[tikv] | table:t0 | keep order:false |
+---------------------------+---------+-----------+---------------+---------------------------------------------------------------------------------------------------------------+ |
ti-chi-bot
bot
added
may-affects-5.4
This bug maybe affects 5.4.x versions.
may-affects-6.1
may-affects-6.5
may-affects-7.1
may-affects-7.5
labels
Feb 28, 2024
The root cause is the same as #51290 |
windtalker
added
sig/planner
SIG: Planner
and removed
sig/execution
SIG execution
labels
Mar 5, 2024
it has been fixed by #53235 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
affects-8.1
This bug affects the 8.1.x(LTS) versions.
may-affects-5.4
This bug maybe affects 5.4.x versions.
may-affects-6.1
may-affects-6.5
may-affects-7.1
may-affects-7.5
severity/major
sig/planner
SIG: Planner
type/bug
The issue is confirmed as a bug.
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
2. What did you expect to see? (Required)
The following two sqls should return the same result
3. What did you see instead (Required)
These two sqls return different results. If change
LEFT JOIN
toRIGHT JOIN
, you also get the same result as the one below.4. What is your TiDB version? (Required)
TiDB-v7.6.0
The text was updated successfully, but these errors were encountered: