pingcap / pingcap/tidb

Unexpected Results by LEFT JOIN

Open
#51,523 2 comments 0 reactions 0 assignees View on GitHub
fuzz/sqlancer severity/moderate sig/planner type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

### 1. Minimal reproduce step (Required)

```sql
CREATE TABLE t0(c0 INT UNSIGNED, c1 INT UNSIGNED, c2 BOOL);
CREATE TABLE t1 LIKE t0;
INSERT IGNORE INTO t0 VALUES (1, -2, true);

SELECT FIELD(t0.c1, '', t1.c1, 2) FROM t0 LEFT JOIN t1 ON t0.c0; -- {1}
SELECT * FROM t0 LEFT JOIN t1 ON t0.c0 WHERE FIELD(t0.c1, '', t1.c1, 2); -- empty set
```

### 2. What did you expect to see? (Required)
The expression `FIELD(t0.c1, '', t1.c1, 2)` is evaluated to be true for the first query, but false for the second query.

### 3. What did you see instead (Required)
The second query returns a row.

### 4. What is your TiDB version? (Required)

```
| Release Version: v7.6.0-alpha-347-g598ccada40
Edition: Community
Git Commit Hash: 598ccada4065e4871bc5bce53a039cbb598a6d82
Git Branch: master
UTC Build Time: 2024-03-04 06:43:19
GoVersion: go1.21.0
Race Enabled: false
Check Table Before Drop: false
Store: unistore |
```

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.