pingcap/tidb
View on GitHubTiDB is not compatible with MySQL 5.7 when using incomplete DateTime format
Open
#22,088 opened on Dec 30, 2020
help wantedtype/compatibility
Description
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
MySQL [test]> create table t_d (id int,c1 datetime);
Query OK, 0 rows affected (1.05 sec)
MySQL [test]> insert into t_d (id,c1) values (1,'2020-01-02'),(2,'2020-02-02');
Query OK, 2 rows affected (0.03 sec)
Records: 2 Duplicates: 0 Warnings: 0
MySQL [test]> select * from t_d where c1 > '2020-01';
Empty set, 1 warning (0.01 sec)
MySQL [test]> select * from t_d where c1 > '2020-01-01';
+------+---------------------+
| id | c1 |
+------+---------------------+
| 1 | 2020-01-02 00:00:00 |
| 2 | 2020-02-02 00:00:00 |
+------+---------------------+
2 rows in set (0.00 sec)
2. What did you expect to see? (Required)
Just like MySQL
Database changed
MySQL [test]> create table t_d (id int,c1 datetime);
Query OK, 0 rows affected (0.02 sec)
MySQL [test]> insert into t_d (id,c1) values (1,'2020-01-02'),(2,'2020-02-02');
Query OK, 2 rows affected (0.00 sec)
Records: 2 Duplicates: 0 Warnings: 0
MySQL [test]> select * from t_d where c1 > '2020-01';
+------+---------------------+
| id | c1 |
+------+---------------------+
| 1 | 2020-01-02 00:00:00 |
| 2 | 2020-02-02 00:00:00 |
+------+---------------------+
2 rows in set, 1 warning (0.00 sec)
MySQL [test]> select @@version;
+-----------------+
| @@version |
+-----------------+
| 5.6.48-88.0-log |
+-----------------+
1 row in set (0.00 sec)
3. What did you see instead (Required)
Nothing returned in TiDB
MySQL [test]> select * from t_d where c1 > '2020-01';
Empty set, 1 warning (0.01 sec)
4. What is your TiDB version? (Required)
MySQL [test]> select tidb_version();
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v4.0.8
Edition: Community
Git Commit Hash: 66ac9fc31f1733e5eb8d11891ec1b38f9c422817
Git Branch: heads/refs/tags/v4.0.8
UTC Build Time: 2020-10-30 08:21:16
GoVersion: go1.13
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)