Incorrect results of SELECT caused by JOIN table
- 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)
**Setup the environment:**
```
CREATE TABLE t4 (vkey int(11), c13 double);
INSERT INTO t4 VALUES (31,0);
CREATE TABLE t7 (vkey int(11), pkey int(11), c26 double, c27 int(11));
INSERT INTO t7 VALUES (29,164000,0,NULL);
```
**Testcase 1**
```
select 1 as c0
from
(t7 as ref_0
inner join (t7 as ref_1
right join t4 as ref_2
on (ref_1.vkey = ref_2.vkey ))
on (ref_0.c26 = ref_2.c13 ))
where not (not (
(nullif(ref_0.pkey, ref_1.c27) is not null) and false
));
```
Testcase 1 outputs 1 row.
```
+----+
| c0 |
+----+
| 1 |
+----+
1 row in set (0.00 sec)
```
Then, I replace `(nullif(ref_0.pkey, ref_1.c27) is not null) and false` with `false`. The results should not be changed because `anything and false` is `false`. The test case becomes:
**Testcase 2**
```
select 1 as c0
from
(t7 as ref_0
inner join (t7 as ref_1
right join t4 as ref_2
on (ref_1.vkey = ref_2.vkey ))
on (ref_0.c26 = ref_2.c13 ))
where not (not (
false
));
```
### 2. What did you expect to see? (Required)
Testcase 1 and Testcase 2 should output the same results.
### 3. What did you see instead (Required)
Testcase 2 outputs
```
Empty set (0.00 sec)
```
While Testcase 1 outputs:
```
+----+
| c0 |
+----+
| 1 |
+----+
1 row in set (0.00 sec)
```
### 4. What is your TiDB version? (Required)
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v7.1.0-alpha-27-gf5ca27ef3
Edition: Community
Git Commit Hash: f5ca27ef326e94fb29b4ba35a5d59aa575f66880
Git Branch: master
UTC Build Time: 2023-03-23 13:57:53
GoVersion: go1.20.2
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: unistore |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Contributor guide
Assessment
This issue has not been assessed yet.