pingcap / pingcap/tidb

Unexpected Result by DATE_FORMAT function

Open
#60,624 2 comments 0 reactions 0 assignees View on GitHub
fuzz/sqlancer 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)

```sql
CREATE TABLE t0(c0 INT ZEROFILL);
INSERT IGNORE INTO t0(c0) VALUES (-1);
SELECT t0.c0 FROM t0; -- {0}
SELECT t0.c0 FROM t0 WHERE NOT DATE_FORMAT(FALSE, t0.c0); -- Empty
```
### 2. What did you expect to see? (Required)
The `INSERT` statement should fail due to the `INT ZEROFILL` column type (if we remove the `IGNORE`, the `INSERT` throws an error), so `t0` should be empty.
However, the first `SELECT` unexpectedly returns one row.
A more strange thing is that `NOT DATE_FORMAT(FALSE, 0)` is evaluated as TRUE. The second `SELECT` should return this one row, but it does not.

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

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

```bash
8.0.11-TiDB-v9.0.0-beta.1.pre-554-gb1a5536a64-dirty
```

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.