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

Add date with a big intervals result incorrect values #49227

Closed
lcwangchao opened this issue Dec 6, 2023 · 0 comments · Fixed by #49228
Closed

Add date with a big intervals result incorrect values #49227

lcwangchao opened this issue Dec 6, 2023 · 0 comments · Fixed by #49228

Comments

@lcwangchao
Copy link
Collaborator

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

> select "1000-01-01 00:00:00" + INTERVAL 9223372036854775808 day;
> select "1000-01-01 00:00:00" + INTERVAL -9223372036854775809 day;
> create table t(a datetime);
> set sql_mode='';
> insert into t values("1000-01-01 00:00:00" + INTERVAL 18446744073709551616 day);

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

In MySQL:

mysql> select "1000-01-01 00:00:00" + INTERVAL 9223372036854775808 day;
+----------------------------------------------------------+
| "1000-01-01 00:00:00" + INTERVAL 9223372036854775808 day |
+----------------------------------------------------------+
| NULL                                                     |
+----------------------------------------------------------+
1 row in set, 1 warning (0.00 sec)

mysql> select "1000-01-01 00:00:00" + INTERVAL -9223372036854775809 day;
+-----------------------------------------------------------+
| "1000-01-01 00:00:00" + INTERVAL -9223372036854775809 day |
+-----------------------------------------------------------+
| NULL                                                      |
+-----------------------------------------------------------+
1 row in set, 2 warnings (0.00 sec)

mysql> insert into t values("1000-01-01 00:00:00" + INTERVAL 18446744073709551616 day); -- insert when sql_mode=''
Query OK, 1 row affected, 2 warnings (0.00 sec)

mysql> select * from t;
+------+
| a    |
+------+
| NULL |
+------+
1 row in set (0.01 sec)

3. What did you see instead (Required)

mysql> select "1000-01-01 00:00:00" + INTERVAL 9223372036854775808 day;
+----------------------------------------------------------+
| "1000-01-01 00:00:00" + INTERVAL 9223372036854775808 day |
+----------------------------------------------------------+
| 1000-01-01 00:00:00                                      |
+----------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select "1000-01-01 00:00:00" + INTERVAL -9223372036854775809 day;
+-----------------------------------------------------------+
| "1000-01-01 00:00:00" + INTERVAL -9223372036854775809 day |
+-----------------------------------------------------------+
| 1000-01-01 00:00:00                                       |
+-----------------------------------------------------------+
1 row in set, 1 warning (0.00 sec)

mysql> insert into t values("1000-01-01 00:00:00" + INTERVAL 18446744073709551616 day);
ERROR 1690 (22003): %s value is out of range in '%s'

4. What is your TiDB version? (Required)

master

mysql> select tidb_version();
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                             |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v7.6.0-alpha
Edition: Community
Git Commit Hash: 795335a7f88da6197221da145c854c2dbfe22f95
Git Branch: heads/refs/tags/v7.6.0-alpha
UTC Build Time: 2023-12-03 14:26:07
GoVersion: go1.21.4
Race Enabled: false
Check Table Before Drop: false
Store: tikv |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant