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

SUBTIME function returns an error in DATETIME type related to TIMESTAMP type #36059

Open
espresso98 opened this issue Jul 8, 2022 · 0 comments
Labels
affects-6.0 affects-6.1 affects-6.2 affects-6.3 affects-6.4 affects-6.5 affects-6.6 affects-7.0 affects-7.1 affects-7.5 affects-8.1 may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. severity/major sig/execution SIG execution type/bug The issue is confirmed as a bug.

Comments

@espresso98
Copy link
Collaborator

Bug Report

1. Minimal reproduce step

CREATE TABLE t1 (a TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6));
INSERT INTO t1 VALUES ('1970-01-01 01:00:01.000000');
INSERT INTO t1 VALUES ('1970-01-01 01:00:01.000001');

CREATE TABLE t2 (
    `SUBTIME(a, '00:00:00.000001')` datetime(6) DEFAULT NULL,
    `SUBTIME(a, '10:00:00.000001')` datetime(6) DEFAULT NULL
);

INSERT INTO t2 SELECT
  SUBTIME(a, '00:00:00.000001'),
  SUBTIME(a, '10:00:00.000001')
FROM t1; 
SELECT * FROM t2;

2. What did you expect to see?

mysql> INSERT INTO t2 SELECT
    ->   SUBTIME(a, '00:00:00.000001'),
    ->   SUBTIME(a, '10:00:00.000001')
    -> FROM t1; 
Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> SELECT * FROM t2;
+-------------------------------+-------------------------------+
| SUBTIME(a, '00:00:00.000001') | SUBTIME(a, '10:00:00.000001') |
+-------------------------------+-------------------------------+
| 1970-01-01 01:00:00.999999    | 1969-12-31 15:00:00.999999    |
| 1970-01-01 01:00:01.000000    | 1969-12-31 15:00:01.000000    |
+-------------------------------+-------------------------------+

3. What did you see instead

tidb> INSERT INTO t2 SELECT
    ->   SUBTIME(a, '00:00:00.000001'),
    ->   SUBTIME(a, '10:00:00.000001')
    -> FROM t1; 
ERROR 1292 (22007): Incorrect time value: '{1969 12 31 15 0 0 999999}'

4. What is your TiDB version?

tidb_version(): Release Version: v6.2.0-alpha-230-g47a4f3a01
Edition: Community
Git Commit Hash: 47a4f3a017768dda0b9a826451486c5539bc8427
Git Branch: master
UTC Build Time: 2022-07-08 20:42:13
GoVersion: go1.18.1
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
Store: unistore
@espresso98 espresso98 added the type/bug The issue is confirmed as a bug. label Jul 8, 2022
@ti-chi-bot ti-chi-bot added may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.0 may-affects-6.1 labels Jul 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-6.0 affects-6.1 affects-6.2 affects-6.3 affects-6.4 affects-6.5 affects-6.6 affects-7.0 affects-7.1 affects-7.5 affects-8.1 may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. severity/major sig/execution SIG execution type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

5 participants