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

date_add/date_sub does not handle invalid date properly #56460

Closed
gengliqi opened this issue Oct 7, 2024 · 1 comment · Fixed by #56461
Closed

date_add/date_sub does not handle invalid date properly #56460

gengliqi opened this issue Oct 7, 2024 · 1 comment · Fixed by #56461
Labels
severity/moderate type/bug The issue is confirmed as a bug.

Comments

@gengliqi
Copy link
Contributor

gengliqi commented Oct 7, 2024

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

mysql> create table t(a int);
Query OK, 0 rows affected (0.07 sec)

mysql> insert into t values(0),(20015),(20100);
Query OK, 3 rows affected (0.02 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql> select date_add(a, interval 12345 DAY_HOUR) from t;
+--------------------------------------+
| date_add(a, interval 12345 DAY_HOUR) |
+--------------------------------------+
| 0001-04-27 09:00:00                  |
| 2003-05-13 09:00:00                  |
| 2003-05-29 09:00:00                  |
+--------------------------------------+
3 rows in set, 3 warnings (0.01 sec)

2. What did you expect to see? (Required)

MySQL 8.0
mysql> create table t(a int);
Query OK, 0 rows affected (0.02 sec)

mysql> insert into t values(0),(20015),(20100);
Query OK, 3 rows affected (0.01 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql> select date_add(a, interval 12345 DAY_HOUR) from t;
+--------------------------------------+
| date_add(a, interval 12345 DAY_HOUR) |
+--------------------------------------+
| NULL                                 |
| NULL                                 |
| NULL                                 |
+--------------------------------------+
3 rows in set, 3 warnings (0.01 sec)

3. What did you see instead (Required)

mysql> select date_add(a, interval 12345 DAY_HOUR) from t;
+--------------------------------------+
| date_add(a, interval 12345 DAY_HOUR) |
+--------------------------------------+
| 0001-04-27 09:00:00                  |
| 2003-05-13 09:00:00                  |
| 2003-05-29 09:00:00                  |
+--------------------------------------+
3 rows in set, 3 warnings (0.01 sec)

4. What is your TiDB version? (Required)

Master

@gengliqi gengliqi added the type/bug The issue is confirmed as a bug. label Oct 7, 2024
@gengliqi
Copy link
Contributor Author

gengliqi commented Oct 7, 2024

/severity moderate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/moderate type/bug The issue is confirmed as a bug.
Projects
None yet
1 participant