Details
-
Task
-
Status: Closed (View Workflow)
-
Blocker
-
Resolution: Fixed
Description
Users new to MariaDB often struggle with the default behavior of MariaDB regarding the datatype timestamp and automatic values https://mariadb.com/kb/en/timestamp/#automatic-values
explicit_defaults_for_timestamp , currently set to OFF by default, should be ON by default.
At the same time it should be checked if the variable can become a dynamic variable and if the scope SESSION can be added.
In effect:
With explicit_defaults_for_timestamp=OFF (default):
MariaDB> CREATE TABLE t1 (a timestamp); |
MariaDB> SHOW CREATE TABLE t1; |
|
CREATE TABLE `t1` ( |
`a` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() |
) ...
|
With explicit_defaults_for_timestamp=ON the result would be:
CREATE TABLE `t1` ( |
`a` timestamp NULL DEFAULT NULL |
) ...
|
MySQL did it in 8.0.2
Attachments
Issue Links
- blocks
-
MDEV-29227 deprecate explicit_defaults_for_timestamp=0
-
- Closed
-
- causes
-
MDEV-29075 Changing explicit_defaults_for_timestamp within stored procedure works inconsistently
-
- Closed
-
-
MDEV-29078 For old binary logs explicit_defaults_for_timestamp presumed to be OFF, server value ignored
-
- Closed
-
-
MDEV-29322 ASAN heap-use-after-free in Query_log_event::do_apply_event, rpl.rpl_mdev10863 fails frequently
-
- Closed
-
- is blocked by
-
MDEV-29225 make explicit_defaults_for_timestamps SESSION variable
-
- Closed
-
- is duplicated by
-
MDEV-28470 Please remove automatic TIMESTAMP update behaviour
-
- Closed
-
- relates to
-
MDEV-28983 TIMESTAMP logic remains partly non-standard with explicit_defaults_for_timestamp
-
- Open
-
Just a few comments.
I think that the variable "explicit_defaults_for_timestamp" has a bad name. I cannot by just looking at:
explicit_defaults_for_timestamp=OFF
understand what it will do.
First, the variable does affect CREATE TABLE, not defaults for existing timestamps.
Why does setting the variable to ON mean that there are are no defaults?
A better name would be something like
timestamp_in_create_table_has_current_time_as_default.
Note also that if we change timestamp to be NULL, it means it will take more storage space and if the user puts an index on the timestamp column, the performance for that index will be about 3-4 times slower (as the index will not anymore be fixed length)