pingcap / pingcap/tidb

Unexpected Inner join result

Open
#61,306 11 comments 0 reactions 1 assignee Claimed by @hawkingrei View on GitHub
affects-8.5 affects-9.0 may-affects-6.1 may-affects-6.5 may-affects-7.1 may-affects-7.5 may-affects-8.1 severity/major sig/planner type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report
Dear TiDB Developers,
I meet some unexpected join results, please see the following cases. I will appreciate it if you can review it.

### 1. Minimal reproduce step (Required)

```sql
CREATE TABLE t1(c0 INT);
CREATE TABLE t3(c0 INT );

INSERT INTO t1 VALUES (1), (2);
INSERT INTO t3(c0) VALUES (-63595);

SELECT t3.c0
FROM t3
INNER JOIN t1 ON (CASE 1
WHEN ((((t3.c0)))) THEN -10
ELSE ((((t1.c0) IS NOT NULL)) / (t3.c0)) END);
-- 2 rows

ALTER TABLE t1 ADD PRIMARY KEY (c0);
-- necessary

SELECT t3.c0
FROM t3
INNER JOIN t1 ON (CASE 1
WHEN ((((t3.c0)))) THEN -10
ELSE ((((t1.c0) IS NOT NULL)) / (t3.c0)) END);
-- empty result
```

### 2. What did you expect to see? (Required)
The two query produces same results.

### 3. What did you see instead (Required)
The two query produces different results.

### 4. What is your TiDB version? (Required)
```
Release Version: v9.0.0-beta.1.pre-801-gd7d62ce0d2
Edition: Community
Git Commit Hash: d7d62ce0d26d15b902361010aab2526a4e2c511f
Git Branch: HEAD
UTC Build Time: 2025-05-25 04:45:44
GoVersion: go1.23.9
Race Enabled: false
Check Table Before Drop: false
Store: tikv
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.