Year type comparison behaves 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)
I'm not sure it's a compatibility problem or not, the year type behaves not same with MySQL, PTAL
#### TiDB
```sql
mysql> select 2009 > date_add('2007-01-01', interval 1 year);
+------------------------------------------------+
| 2009 > date_add('2007-01-01', interval 1 year) |
+------------------------------------------------+
| 1 |
+------------------------------------------------+
1 row in set, 1 warning (0.01 sec)
mysql> select 2008 > date_add('2007-01-01', interval 1 year);
+------------------------------------------------+
| 2008 > date_add('2007-01-01', interval 1 year) |
+------------------------------------------------+
| 0 |
+------------------------------------------------+
1 row in set, 1 warning (0.01 sec)
mysql> show warnings;
+---------+------+------------------------------------------------+
| Level | Code | Message |
+---------+------+------------------------------------------------+
| Warning | 1292 | Truncated incorrect DOUBLE value: '2008-01-01' |
+---------+------+------------------------------------------------+
1 row in set (0.00 sec)
mysql> select tidb_version();
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: None
Edition: Community
Git Commit Hash: None
Git Branch: None
UTC Build Time: None
GoVersion: go1.20.2
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: unistore |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
```
#### MySQL
```sql
mysql> select 2009 > date_add('2007-01-01', interval 1 year);
+------------------------------------------------+
| 2009 > date_add('2007-01-01', interval 1 year) |
+------------------------------------------------+
| 0 |
+------------------------------------------------+
1 row in set (0.00 sec)
mysql> select 2008 > date_add('2007-01-01', interval 1 year);
+------------------------------------------------+
| 2008 > date_add('2007-01-01', interval 1 year) |
+------------------------------------------------+
| 0 |
+------------------------------------------------+
1 row in set (0.01 sec)
mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.31 |
+-----------+
1 row in set (0.01 sec)
```
### 2. What did you expect to see? (Required)
### 3. What did you see instead (Required)
### 4. What is your TiDB version? (Required)
Contributor guide
Assessment
This issue has not been assessed yet.