[MDEV-28632] Change default of explicit_defaults_for_timestamp to ON Created: 2022-05-20 Updated: 2023-07-13 Resolved: 2022-08-10 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Temporal Types |
| Fix Version/s: | 10.10.1 |
| Type: | Task | Priority: | Blocker |
| Reporter: | Ralf Gebhardt | Assignee: | Sergei Golubchik |
| Resolution: | Fixed | Votes: | 3 |
| Labels: | Preview_10.10, incompatibility | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||||||
| 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=ON the result would be:
MySQL did it in 8.0.2 |
| Comments |
| Comment by Elena Stepanova [ 2022-06-14 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
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:
If you add a new column before the first TIMESTAMP, you get two CURRENT_TIMESTAMP columns:
But if you add a new column after an existing TIMESTAMP, you won't:
If you "modify" the first timestamp, it will remain as it is:
If you modify another timestamp, it will lose CURRENT_TIMESTAMP properties:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2022-06-18 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
It's in this branch: preview-10.10-misc. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2022-06-29 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
In the current implementation, I only see the change of the default, but the scope and read-only-ness remained as they were, and there seems to be no activity on MDEV-8455. I don't think it is sufficient. It is clear from the MySQL history that users don't accept the change in this form, because it breaks OM => NS upgrade. There had been multiple complaints about it (example1, example2) which made MySQL start writing it in the binary log, and for this, it was changed to dynamic and session-level. And it was done not only in 8.0 where the default was changed, but in 5.7, to facilitate the rolling upgrade. I think we have to do the same, in as early versions as possible and as soon as possible. While it won't eliminate the OM => NS problem entirely (there will still be ancient pre-change installations and binary logs), it will at least minimize the issue. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2022-08-02 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
The last branch in my testing was bb-10.10- I think the change should be pushed into the target branches. It is not what will be merged into 10.10 main though; the most part of the patch will go to 10.5+ and will be merged up, and only s smaller change will be pushed directly into 10.10. The change which old versions need to facilitate smooth(er) rolling upgrades turned out to be much more intrusive than I originally expected; it is worrisome, but I still believe it is the right thing to do: odd legacy behavior of timestamps has to be eventually abandoned, and given our release model, there is no way to do it other than accompanying it by a change in older post-GA versions. Documentation-wise, I don't think that the switch from read-only to dynamic variable should be anyhow advertised, neither for old versions nor for 10.10; while it is done on technical reasons, we do not actually want users to start changing it at runtime. It is never needed, whatever users want to achieve by changing the variable at runtime, they can do instead by creating a table in a proper manner. What should probably be highlighted for old GAs is that the default value of the variable will change in upcoming versions, so users are advised to start switching their instances to ON value as soon as possible globally, by setting it in the config file. For 10.10, the focus should be on the change of the default, users need to be aware if they rely on the old behavior in their applications. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Michael Widenius [ 2022-11-29 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Just a few comments. I think that the variable "explicit_defaults_for_timestamp" has a bad name. I cannot by just looking at: First, the variable does affect CREATE TABLE, not defaults for existing timestamps. A better name would be something like 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) |