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

Some bugs on date types boundary values #25217

Open
you06 opened this issue Jun 7, 2021 · 1 comment
Open

Some bugs on date types boundary values #25217

you06 opened this issue Jun 7, 2021 · 1 comment
Labels
severity/moderate sig/execution SIG execution type/bug The issue is confirmed as a bug.

Comments

@you06
Copy link
Contributor

you06 commented Jun 7, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

I ran sql-boundary on TiDB, and find the 50 failure cases.

1. Minimal reproduce step (Required)

CREATE TABLE t(c timestamp);
INSERT INTO t VALUES('2038-01-18 03:14:07');
UPDATE t SET c = adddate(c,INTERVAL 48 HOUR);
SELECT * FROM t;

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

Update statement should got failed.

3. What did you see instead (Required)

Update statement successes, the select statement got error.

mysql> SELECT * FROM t;
ERROR 1292 (22007): Incorrect datetime value: '2038-01-20 03:14:07'

4. What is your TiDB version? (Required)

Release Version: v5.1.0-alpha-167-ga8ad9b7d3
Edition: Community
Git Commit Hash: a8ad9b7d3aa53d0181422d2b22fa8d57b7d56db1
Git Branch: master
UTC Build Time: 2021-06-05 07:04:28
GoVersion: go1.16.4
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false

5. Attachment

There are many related bugs.

Manipulate data with different units.
CREATE TABLE t(c timestamp);
INSERT INTO t VALUES('2038-01-18 03:14:07');
UPDATE t SET c = adddate(c,INTERVAL 2880 MINUTE);
SELECT * FROM t;
ERROR 1292 (22007): Incorrect datetime value: '2038-01-20 03:14:07'
CREATE TABLE t(c timestamp);
INSERT INTO t VALUES('2038-01-18 03:14:07');
UPDATE t SET c = adddate(c,INTERVAL 172800 SECOND);
SELECT * FROM t;
ERROR 1292 (22007): Incorrect datetime value: '2038-01-20 03:14:07'
Similar bugs on lower bound.
CREATE TABLE t(c timestamp);
INSERT INTO t VALUES('1970-01-02 00:00:01');
UPDATE t SET c = adddate(c,INTERVAL -48 HOUR);
SELECT * FROM t;
ERROR 1292 (22007): Incorrect datetime value: '1969-12-31 00:00:01'
CREATE TABLE t(c timestamp);
INSERT INTO t VALUES('1970-01-02 00:00:01');
UPDATE t SET c = adddate(c,INTERVAL -2880 MINUTE);
SELECT * FROM t;
ERROR 1292 (22007): Incorrect datetime value: '1969-12-31 00:00:01'
Similar bugs on other functions.
CREATE TABLE t(c timestamp);
INSERT INTO t VALUES('2038-01-18 03:14:07');
UPDATE t SET c = subdate(c,INTERVAL -48 HOUR);
SELECT * FROM t;
ERROR 1292 (22007): Incorrect datetime value: '2038-01-20 03:14:07'
Similar bugs on other data types.
CREATE TABLE t(c datetime);
INSERT INTO t VALUES('9999-12-30 23:59:59');
UPDATE t SET c = subtime(c,'-3 0:0:0');
SELECT * FROM t;
+---------------------+
| c                   |
+---------------------+
| 1816-04-01 05:56:07 |
+---------------------+

Notice this update should fail and the read value is strange.

@you06 you06 added the type/bug The issue is confirmed as a bug. label Jun 7, 2021
@wshwsh12 wshwsh12 self-assigned this Jun 8, 2021
@wshwsh12 wshwsh12 removed their assignment Jun 15, 2021
@jyz0309 jyz0309 self-assigned this Jul 13, 2021
@jyz0309 jyz0309 removed their assignment Jul 22, 2021
@dveeden
Copy link
Contributor

dveeden commented Oct 29, 2021

I can't reproduce the issue on v5.2.1

 MySQL  127.0.0.1:4000  test  SQL > SELECT tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v5.2.1
Edition: Community
Git Commit Hash: cd8fb24c5f7ebd9d479ed228bb41848bd5e97445
Git Branch: heads/refs/tags/v5.2.1
UTC Build Time: 2021-09-08 02:32:56
GoVersion: go1.16.4
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
1 row in set (0.0006 sec)
 MySQL  127.0.0.1:4000  test  SQL > CREATE TABLE t(c timestamp);
Query OK, 0 rows affected (0.1110 sec)
 MySQL  127.0.0.1:4000  test  SQL > INSERT INTO t VALUES('2038-01-18 03:14:07');
Query OK, 1 row affected (0.0216 sec)
 MySQL  127.0.0.1:4000  test  SQL > UPDATE t SET c = adddate(c,INTERVAL 48 HOUR);
ERROR: 1292 (22007): Incorrect timestamp value: '2038-01-20 03:14:07'
 MySQL  127.0.0.1:4000  test  SQL > SELECT * FROM t;
+---------------------+
| c                   |
+---------------------+
| 2038-01-18 03:14:07 |
+---------------------+
1 row in set (0.0034 sec)

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

No branches or pull requests

5 participants