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

column type change will write the invalid timestamp value #26292

Closed
AilinKid opened this issue Jul 16, 2021 · 3 comments · Fixed by #26362
Closed

column type change will write the invalid timestamp value #26292

AilinKid opened this issue Jul 16, 2021 · 3 comments · Fixed by #26362
Assignees
Labels
severity/critical sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@AilinKid
Copy link
Contributor

AilinKid commented Jul 16, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

Only can reproduce it Real TiKV Cluster

CREATE TABLE `t` (`a` DATE NULL DEFAULT '8497-01-06');
alter table t modify column a  TIMESTAMP NULL DEFAULT '2021-04-28 03:35:11' FIRST"; // hang it
insert into `t` set  `a` = '3977-02-22'   //  在 write only 及之后状态写下去

Maybe the root cause is

mysql> select cast('3977-02-22' as datetime);
+--------------------------------+
| cast('3977-02-22' as datetime) |
+--------------------------------+
| 3977-02-22 00:00:00            |
+--------------------------------+
1 row in set (0.00 sec)

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

DML failed with incorrect value

3. What did you see instead (Required)

DML succeed and the latter select fail with incorrect value

4. What is your TiDB version? (Required)

master

@AilinKid AilinKid added the type/bug The issue is confirmed as a bug. label Jul 16, 2021
@zimulala
Copy link
Contributor

We can check why the normal insert will return an error, but the WriteOnly insert is normal.

tidb> CREATE TABLE `t` (`a` DATE NULL DEFAULT '8497-01-06', `b` TIMESTAMP NULL DEFAULT '2021-04-28 03:35:11');
Query OK, 0 rows affected (0.01 sec)
tidb> insert into `t` set  `b` = '3977-02-22' ;
ERROR 1292 (22007): Incorrect timestamp value: '3977-02-22' for column 'b' at row 1

@AilinKid
Copy link
Contributor Author

quick similar like #25560

mysql> select timestamp(cast("3977-02-22" as date));
+---------------------------------------+
| timestamp(cast("3977-02-22" as date)) |
+---------------------------------------+
| 3977-02-22 00:00:00                   |
+---------------------------------------+
1 row in set (0.01 sec)

1: when in pure insert statement, cast "3977-02-22" to timestamp will errors (incorrest timestamp value)

2: when in mid-state insert statement, cast "3977-02-22" to date datum first, then the changing col cast date datum to timestamp, which is ok here.

@ti-srebot
Copy link
Contributor

Please edit this comment or add a new comment to complete the following information

Not a bug

  1. Remove the 'type/bug' label
  2. Add notes to indicate why it is not a bug

Duplicate bug

  1. Add the 'type/duplicate' label
  2. Add the link to the original bug

Bug

Note: Make Sure that 'component', and 'severity' labels are added
Example for how to fill out the template: #20100

1. Root Cause Analysis (RCA) (optional)

2. Symptom (optional)

3. All Trigger Conditions (optional)

4. Workaround (optional)

5. Affected versions

6. Fixed versions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/critical sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants