pingcap/tidb
Auf GitHub ansehenzeroDate behavior for date_add and timestampdiff is not consistent in tidb
Open
#15.234 geöffnet am 9. März 2020
component/expressionhelp wantedseverity/moderatesig/executiontype/bug
Repository-Metriken
- Stars
- (40.090 Stars)
- PR-Merge-Metriken
- (Durchschn. Merge 14T 4h) (346 gemergte PRs in 30 T)
Beschreibung
Description
Bug Report
Please answer these questions before submitting your issue. Thanks!
- What did you do?
mysql> select timestampdiff(day,'0000-00-00 00:00:00','2020-01-01 00:00:00');
+----------------------------------------------------------------+
| timestampdiff(day,'0000-00-00 00:00:00','2020-01-01 00:00:00') |
+----------------------------------------------------------------+
| NULL |
+----------------------------------------------------------------+
1 row in set, 1 warning (0.00 sec)
mysql> select date_add('0000-00-00 00:00:00', interval 2020 year);
+-----------------------------------------------------+
| date_add('0000-00-00 00:00:00', interval 2020 year) |
+-----------------------------------------------------+
| 2019-11-30 00:00:00 |
+-----------------------------------------------------+
1 row in set, 1 warning (0.00 sec)
-
What did you expect to see? timestampdiff and date_add should both return NULL or meaningful result. BTW in mysql both timestampdiff and date_add return NULL
-
What did you see instead?
mysql> select timestampdiff(day,'0000-00-00 00:00:00','2020-01-01 00:00:00');
+----------------------------------------------------------------+
| timestampdiff(day,'0000-00-00 00:00:00','2020-01-01 00:00:00') |
+----------------------------------------------------------------+
| NULL |
+----------------------------------------------------------------+
1 row in set, 1 warning (0.00 sec)
mysql> select date_add('0000-00-00 00:00:00', interval 2020 year);
+-----------------------------------------------------+
| date_add('0000-00-00 00:00:00', interval 2020 year) |
+-----------------------------------------------------+
| 2019-11-30 00:00:00 |
+-----------------------------------------------------+
1 row in set, 1 warning (0.00 sec)
- What version of TiDB are you using (
tidb-server -Vor runselect tidb_version();on TiDB)?
tidb master