comparison with "0000-00-00 00:00:00" different between MySQL and TiDB
- 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)
```
mysql> create table test123( cdate datetime );
mysql> insert into test123 values (now());
mysql> select * from test123 where cdate>"0000-00-00 00:00:00";
mysql> select * from test123 where cdate>"0000-00-00 00:00:01";
```
### 2. What did you expect to see? (Required)
in MySQL, both select queries return the `now()` value entered in the second line:
```
mysql> select * from test123 where cdate>"0000-00-00 00:00:00";
+---------------------+
| cdate |
+---------------------+
| 2022-04-25 09:46:24 |
+---------------------+
1 row in set (0.00 sec)
mysql> select * from test123 where cdate>"0000-00-00 00:00:01";
+---------------------+
| cdate |
+---------------------+
| 2022-04-25 09:46:24 |
+---------------------+
1 row in set (0.00 sec)
```
### 3. What did you see instead (Required)
the comparison with "0000-00-00 00:00:00" fails
```
MySQL [user32]> select * from test123 where cdate>"0000-00-00 00:00:00";
Empty set, 1 warning (0.038 sec)
MySQL [user32]> select * from test123 where cdate>"0000-00-00 00:00:01";
+---------------------+
| cdate |
+---------------------+
| 2022-04-25 09:43:30 |
+---------------------+
1 row in set (0.020 sec)
```
### 4. What is your TiDB version? (Required)
```
MySQL [user32]> select tidb_version() \G
*************************** 1. row ***************************
tidb_version(): Release Version: v6.0.0
Edition: Community
Git Commit Hash: 36a9810441ca0e496cbd22064af274b3be771081
Git Branch: heads/refs/tags/v6.0.0
UTC Build Time: 2022-03-31 10:33:28
GoVersion: go1.18
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
```
Contributor guide
Assessment
This issue has not been assessed yet.