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
-
A few examples to remind of the oddities caused by the current default behavior (with explicit_defaults_for_timestamp=OFF).
Only the first TIMESTAMP column gets the CURRENT_TIMESTAMP, but all TIMESTAMP columns get implicit NOT NULL and some default:
*************************** 1. row ***************************
If you add a new column before the first TIMESTAMP, you get two CURRENT_TIMESTAMP columns:
Records: 0 Duplicates: 0 Warnings: 0
*************************** 1. row ***************************
But if you add a new column after an existing TIMESTAMP, you won't:
Records: 0 Duplicates: 0 Warnings: 0
*************************** 1. row ***************************
If you "modify" the first timestamp, it will remain as it is:
Records: 0 Duplicates: 0 Warnings: 0
*************************** 1. row ***************************
If you modify another timestamp, it will lose CURRENT_TIMESTAMP properties:
Records: 0 Duplicates: 0 Warnings: 0
*************************** 1. row ***************************