Bug #105829 | DEFAULT(timestamp_col) is different from DEFAULT for timestamp columns (NULL) | ||
---|---|---|---|
Submitted: | 8 Dec 2021 10:52 | Modified: | 8 Dec 2021 16:10 |
Reporter: | Mattias Jonsson | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: DML | Severity: | S3 (Non-critical) |
Version: | 8.0.27 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[8 Dec 2021 10:52]
Mattias Jonsson
[8 Dec 2021 13:58]
MySQL Verification Team
Hi Mr. Jonsson, Thank you for your bug report. However, this is not a bug. You are quite right that DEFAULT with braces should return defined value, but that is not valid for TIMESTAMP / DATETIME domains, as explained in our Reference Manual, section 11.2.5. Not a bug.
[8 Dec 2021 16:10]
Mattias Jonsson
Thanks for the explanation, but I cannot see any references about DEFAULT(timestamp_col) in the manual section 11.2.5. But I could find a part that may be appropriate in 11.6: "However, the use of DEFAULT(col_name) to specify the default value for a named column is permitted only for columns that have a literal default value, not for columns that have an expression default value." Which is clear with this example: create table t (a int primary key, b int default (3 + 2)); insert into t (a) values (1); mysql> select default(b) from t; ERROR 3773 (HY000): DEFAULT function cannot be used with default value expressions But then I would expect an error when doing it with 'b timestamp default current_timestamp' too, and not silently insert NULL for the second row in the 'How to repeat' section!