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

DDL set default timestamp value is not correct. #31968

Closed
Alkaagr81 opened this issue Jan 25, 2022 · 3 comments · Fixed by #32384
Closed

DDL set default timestamp value is not correct. #31968

Alkaagr81 opened this issue Jan 25, 2022 · 3 comments · Fixed by #32384
Assignees
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. severity/moderate sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@Alkaagr81
Copy link
Collaborator

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

SET timestamp = 1000;
drop table if exists t1;
CREATE TABLE t1 ( b INT );
INSERT INTO t1 VALUES (1),(2);
ALTER TABLE t1 ADD COLUMN a6 DATETIME(6) DEFAULT NOW(6) ON UPDATE NOW(6) FIRST;
ALTER TABLE t1 ADD COLUMN a5 DATETIME(6) DEFAULT NOW(6) FIRST;
ALTER TABLE t1 ADD COLUMN a4 DATETIME(6) ON UPDATE NOW(6) FIRST;
select * from t1;

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

mysql> SET timestamp = 1000;
Query OK, 0 rows affected (0.00 sec)

mysql> drop table if exists t1;
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE TABLE t1 ( b INT );
Query OK, 0 rows affected (0.00 sec)

mysql> INSERT INTO t1 VALUES (1),(2);
Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql>  ALTER TABLE t1 ADD COLUMN a6 DATETIME(6) DEFAULT NOW(6) ON UPDATE NOW(6) FIRST;
Query OK, 0 rows affected (0.01 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql>  ALTER TABLE t1 ADD COLUMN a5 DATETIME(6) DEFAULT NOW(6) FIRST;
Query OK, 0 rows affected (0.01 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql>  ALTER TABLE t1 ADD COLUMN a4 DATETIME(6) ON UPDATE NOW(6) FIRST;
Query OK, 0 rows affected (0.01 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> 
mysql>  select * from t1;
+------+----------------------------+----------------------------+------+
| a4   | a5                         | a6                         | b    |
+------+----------------------------+----------------------------+------+
| NULL | 1969-12-31 19:16:40.000000 | 1969-12-31 19:16:40.000000 |    1 |
| NULL | 1969-12-31 19:16:40.000000 | 1969-12-31 19:16:40.000000 |    2 |
+------+----------------------------+----------------------------+------+
2 rows in set (0.00 sec)

3. What did you see instead (Required)

mysql> SET timestamp = 1000;
Query OK, 0 rows affected (0.00 sec)

mysql> drop table if exists t1;
Query OK, 0 rows affected (0.01 sec)

mysql> CREATE TABLE t1 ( b INT );
Query OK, 0 rows affected (0.01 sec)

mysql> INSERT INTO t1 VALUES (1),(2);
Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql>  ALTER TABLE t1 ADD COLUMN a6 DATETIME(6) DEFAULT NOW(6) ON UPDATE NOW(6) FIRST;
Query OK, 0 rows affected (0.01 sec)

mysql>  ALTER TABLE t1 ADD COLUMN a5 DATETIME(6) DEFAULT NOW(6) FIRST;
Query OK, 0 rows affected (0.01 sec)

mysql>  ALTER TABLE t1 ADD COLUMN a4 DATETIME(6) ON UPDATE NOW(6) FIRST;
Query OK, 0 rows affected (0.01 sec)

mysql> 
mysql>  select * from t1;
+------+----------------------------+----------------------------+------+
| a4   | a5                         | a6                         | b    |
+------+----------------------------+----------------------------+------+
| NULL | 2022-01-26 12:29:23.624460 | 2022-01-26 12:29:23.613093 |    1 |
| NULL | 2022-01-26 12:29:23.624460 | 2022-01-26 12:29:23.613093 |    2 |
+------+----------------------------+----------------------------+------+
2 rows in set (0.00 sec)

4. What is your TiDB version? (Required)

| Release Version: v5.5.0-alpha-60-g8c70432b0-dirty
Edition: Community
Git Commit Hash: 8c70432b000d648e9ea26cc57a7fe79d2e67d341
Git Branch: master
UTC Build Time: 2022-01-26 16:56:34
GoVersion: go1.16.9
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |
@Alkaagr81 Alkaagr81 added the type/bug The issue is confirmed as a bug. label Jan 25, 2022
@bb7133 bb7133 added sig/sql-infra SIG: SQL Infra help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. and removed sig/execution SIG execution labels Jan 27, 2022
@CbcWestwolf
Copy link
Member

/assign

@mjonss
Copy link
Contributor

mjonss commented Feb 7, 2022

Is this related to #29585 ?

@CbcWestwolf
Copy link
Member

Is this related to #29585 ?

It is caused by missing implementation. SET timestamp = 1000; select now(); doesn't has this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. severity/moderate 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.

5 participants