Different evaluation of (NOT (expr1 OR expr2) IS FALSE) in WHERE clause after RIGHT JOIN compared to MySQL
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
Please answer these questions before submitting your issue. Thanks!
### 1. Minimal reproduce step (Required)
```sql
DROP TABLE IF EXISTS t0;
DROP TABLE IF EXISTS t1;
CREATE TABLE t0(c0 INT UNSIGNED , PRIMARY KEY(c0));
CREATE TABLE t1 LIKE t0;
INSERT INTO t0(c0) VALUES (0), (2089861764);
INSERT INTO t1(c0) VALUES (209221961), (0), (1423501587);
SELECT true
FROM t0
RIGHT JOIN t1 ON t0.c0 = t1.c0
WHERE (NOT (t1.c0 OR t0.c0) IS FALSE);
```
### 2. What did you expect to see? (Required)
mysql execute result
```shell
mysql> SELECT true
-> FROM t0
-> RIGHT JOIN t1 ON t0.c0 = t1.c0
-> WHERE (NOT (t1.c0 OR t0.c0) IS FALSE);
+------+
| true |
+------+
| 1 |
| 1 |
+------+
2 rows in set (0.00 sec)
mysql> select version();
+-----------+
| version() |
+-----------+
| 8.4.1 |
+-----------+
1 row in set (0.00 sec)
```
### 3. What did you see instead (Required)
```shell
mysql> SELECT true
-> FROM t0
-> RIGHT JOIN t1 ON t0.c0 = t1.c0
-> WHERE (NOT (t1.c0 OR t0.c0) IS FALSE);
+------+
| TRUE |
+------+
| 1 |
| 1 |
| 1 |
+------+
3 rows in set (0.00 sec)
mysql> select version();
+--------------------------------------------+
| version() |
+--------------------------------------------+
| 8.0.11-TiDB-v9.0.0-beta.1.pre-918-g4419a28 |
+--------------------------------------------+
1 row in set (0.00 sec)
mysql> EXPLAIN SELECT true
-> FROM t0
-> RIGHT JOIN t1 ON t0.c0 = t1.c0
-> WHERE (NOT (t1.c0 OR t0.c0) IS FALSE);
+---------------------------------+---------+-----------+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| id | estRows | task | access object | operator info |
+---------------------------------+---------+-----------+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Projection_7 | 2.40 | root | | 1->Column#3 |
| └─Selection_8 | 2.40 | root | | not(isfalse(or(tidb_htap_base13.t1.c0, tidb_htap_base13.t0.c0))) |
| └─IndexJoin_10 | 3.00 | root | | right outer join, inner:TableReader_25, left side:TableReader_25, outer key:tidb_htap_base13.t1.c0, inner key:tidb_htap_base13.t0.c0, equal cond:eq(tidb_htap_base13.t1.c0, tidb_htap_base13.t0.c0) |
| ├─TableReader_27(Build) | 3.00 | root | | data:TableFullScan_26 |
| │ └─TableFullScan_26 | 3.00 | cop[tikv] | table:t1 | keep order:false, stats:pseudo |
| └─TableReader_25(Probe) | 2.00 | root | | data:Selection_24 |
| └─Selection_24 | 2.00 | cop[tikv] | | not(isfalse(or(tidb_htap_base13.t0.c0, tidb_htap_base13.t0.c0))) |
| └─TableRangeScan_23 | 2.50 | cop[tikv] | table:t0 | range: decided by [tidb_htap_base13.t1.c0], keep order:false, stats:pseudo |
+---------------------------------+---------+-----------+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
8 rows in set (0.00 sec)
```
### 4. What is your TiDB version? (Required)
mysql> select tidb_version();
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v9.0.0-beta.1.pre-918-g4419a28
Edition: Community
Git Commit Hash: 4419a28eb9cd988a7f2959c400aa21a63ee884fa
Git Branch: HEAD
UTC Build Time: 2025-06-11 05:47:23
GoVersion: go1.23.10
Race Enabled: false
Check Table Before Drop: false
Store: tikv
Kernel Type: Classic |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
Contributor guide
Assessment
This issue has not been assessed yet.