Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zeroDate behavior for date_add and timestampdiff is not consistent in tidb #15234

Open
windtalker opened this issue Mar 9, 2020 · 5 comments
Labels
component/expression help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. severity/moderate sig/execution SIG execution type/bug The issue is confirmed as a bug.

Comments

@windtalker
Copy link
Contributor

windtalker commented Mar 9, 2020

Description

Bug Report

Please answer these questions before submitting your issue. Thanks!

  1. 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)
  1. 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

  2. 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)
  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?

tidb master

@windtalker windtalker added the type/bug The issue is confirmed as a bug. label Mar 9, 2020
@SunRunAway SunRunAway added the help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. label Mar 10, 2020
@zhangysh1995

This comment has been minimized.

@ti-challenge-bot

This comment has been minimized.

@ti-challenge-bot

This comment has been minimized.

@ti-challenge-bot ti-challenge-bot bot removed the picked label Sep 22, 2020
@zhangysh1995

This comment has been minimized.

@ti-challenge-bot

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. severity/moderate sig/execution SIG execution type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants