pingcap / pingcap/tidb

Unexpected Result by MERGE_JOIN

Open
#47,345 7 comments 1 reaction 3 assignees Claimed by @hawkingrei View on GitHub
affects-6.5 affects-7.1 affects-7.5 affects-8.1 affects-8.5 fuzz/sqlancer may-affects-5.3 may-affects-5.4 may-affects-6.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

Please answer these questions before submitting your issue. Thanks!

### 1. Minimal reproduce step (Required)

```sql
CREATE TABLE t0(c0 INT, c1 INT, c2 INT, PRIMARY KEY(c1));
CREATE TABLE t1 LIKE t0;
INSERT INTO t0 VALUES (1, 2, 3);
CREATE VIEW v0(c0, c1, c2) AS SELECT 4, 5, 6 FROM t1;
INSERT INTO t1 VALUES (7, 8, 9);

SELECT t0.c1 FROM t1, t0 NATURAL RIGHT JOIN v0 WHERE t0.c2 = t1.c2 NOT REGEXP 1; -- {NULL}
SELECT /*+ MERGE_JOIN(t0, t1, v0)*/t0.c1 FROM t1, t0 NATURAL RIGHT JOIN v0 WHERE t0.c2 = t1.c2 NOT REGEXP 1; -- empty set
```

### 2. What did you expect to see? (Required)
Both queries should return the same result, but not.

### 3. What did you see instead (Required)

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

```bash
| Release Version: v7.4.0-alpha
Edition: Community
Git Commit Hash: 32540a4a77984744dc0309d9287b05c8e9593252
Git Branch: heads/refs/tags/v7.4.0-alpha
UTC Build Time: 2023-09-27 14:33:24
GoVersion: go1.21.1
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.