pingcap / pingcap/tidb

Incorrect Join Result under the condition containing date_format, REGEXP and additional true expression

Open
#60,126 3 comments 0 reactions 0 assignees View on GitHub
component/coprocessor severity/moderate sig/execution 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)

```
CREATE TABLE t0(c0 BOOL);
CREATE TABLE t1 LIKE t0;

INSERT INTO t0 VALUES (false);
INSERT INTO t1 VALUES (false);

SELECT *
FROM t1
INNER JOIN t0 ON ((((((DATE_FORMAT(t0.c0, (t0.c0))) < (t1.c0))) REGEXP (t0.c0))));

SELECT *
FROM t1
INNER JOIN t0 ON ((((((DATE_FORMAT(t0.c0, (t0.c0))) < (t1.c0))) REGEXP (t0.c0))) AND (((t0.c0) = (t1.c0))));

```

### 2. What did you expect to see? (Required)
Regarding t0.c0 is false and t1.c0 is false, the expression `(t0.c0) = (t1.c0)` is always true.
So the expected results should be:
```
Q1:
0, 0

Q2:
0, 0
```

### 3. What did you see instead (Required)
```
Q1:
0, 0

Q2:
empty result
```

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

```
Release Version: v9.0.0-beta.1.pre-389-g21f9bb7b7a
Edition: Community
Git Commit Hash: 21f9bb7b7a7478d825c4dee4fbf2ce913e3e7cf1
Git Branch: HEAD
UTC Build Time: 2025-03-11 09:37:34
GoVersion: go1.23.7
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.