pingcap / pingcap/tidb

Unexpected Results by NATURE RIGHT JOIN

Open
#51,490 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 ZEROFILL);
CREATE TABLE t1(c0 INT ZEROFILL);
INSERT IGNORE INTO t0 VALUES (-1);
INSERT IGNORE INTO t1 VALUES (-2);

SELECT t1.c0 FROM t1 NATURAL RIGHT JOIN t0; -- {0}
SELECT t1.c0 FROM t1 NATURAL RIGHT JOIN t0 WHERE IS_IPV4(t0.c0) REGEXP CONCAT_WS('a', FALSE, t1.c0); -- {NULL}
```

### 2. What did you expect to see? (Required)
The second query should return a subset of the results of the first query.

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

### 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.