Wrong result when timestamp compares to 0/false
- 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
DROP TABLE IF EXISTS t0;
CREATE TABLE t0(c0 TIMESTAMP , PRIMARY KEY(c0));
INSERT IGNORE INTO t0(c0) VALUES (NULL);
SELECT ((t0.c0)=(0)) FROM t0;
SELECT t0.c0 FROM t0 WHERE ((t0.c0)=(0));
SELECT ((t0.c0)=(false)) FROM t0;
SELECT t0.c0 FROM t0 WHERE ((t0.c0)=(false));
```
### 2. What did you expect to see? (Required)
see the following case:
### 3. What did you see instead (Required)
```sql
-- MySQL 8.4.1
mysql> SELECT ((t0.c0)=(0)) FROM t0;
+---------------+
| ((t0.c0)=(0)) |
+---------------+
| 1 |
+---------------+
1 row in set (0.01 sec)
mysql> SELECT t0.c0 FROM t0 WHERE ((t0.c0)=(0));
+---------------------+
| c0 |
+---------------------+
| 0000-00-00 00:00:00 |
+---------------------+
1 row in set (0.00 sec)
mysql> SELECT ((t0.c0)=(false)) FROM t0;
+-------------------+
| ((t0.c0)=(false)) |
+-------------------+
| 1 |
+-------------------+
1 row in set (0.00 sec)
mysql> SELECT t0.c0 FROM t0 WHERE ((t0.c0)=(false));
+---------------------+
| c0 |
+---------------------+
| 0000-00-00 00:00:00 |
+---------------------+
1 row in set (0.01 sec)
-- TiDB
mysql> SELECT ((t0.c0)=(0)) FROM t0;
+---------------+
| ((t0.c0)=(0)) |
+---------------+
| 1 |
+---------------+
1 row in set (0.04 sec)
mysql> SELECT t0.c0 FROM t0 WHERE ((t0.c0)=(0));
Empty set (0.03 sec)
mysql> SELECT ((t0.c0)=(false)) FROM t0;
+-------------------+
| ((t0.c0)=(false)) |
+-------------------+
| 1 |
+-------------------+
1 row in set (0.03 sec)
mysql> SELECT t0.c0 FROM t0 WHERE ((t0.c0)=(false));
Empty set (0.04 sec)
```
### 4. What is your TiDB version? (Required)
mysql> select version();
+--------------------+
| version() |
+--------------------+
| 8.0.11-TiDB-v8.5.0 |
+--------------------+
1 row in set (0.04 sec)
Contributor guide
Assessment
This issue has not been assessed yet.