[MDEV-28983] TIMESTAMP logic remains partly non-standard with explicit_defaults_for_timestamp Created: 2022-06-29 Updated: 2023-11-28 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Temporal Types |
| Affects Version/s: | 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10 |
| Fix Version/s: | 10.4, 10.5, 10.6 |
| Type: | Bug | Priority: | Major |
| Reporter: | Elena Stepanova | Assignee: | Sergei Golubchik |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | upstream-fixed | ||
| Issue Links: |
|
||||||||||||
| Description |
|
Note: Even though this is an old known issue not specific to 10.10, I think it becomes much more important now when With explicit_defaults_for_timestamp, if a TIMESTAMP column is defined as NOT NULL without a default value, it still partially retains an implicit (only undeclared) logic and gets a current timestamp value if NULL is attempted to be inserted. Run with --mysqld=--explicit-defaults-for-timestamp=on
|
| Comments |
| Comment by Sergei Golubchik [ 2022-07-12 ] | ||
|
That's different. It's a timestamp behavior on NULL. If you'd try
you'd get "no default" error. If you'd set a default for your table, like
then NULL would still insert CURRENT_TIMESTAMP, while () would insert the default value. | ||
| Comment by Elena Stepanova [ 2022-07-12 ] | ||
|
Yes, I know. I didn't say it was a default, it's non-standard timestamp logic, while explicit_defaults_for_timestamp presumes making timestamps behave the same as other column types. Of course, in MariaDB KB the variable is barely documented at all, so one can argue that we didn't promise anything other than the change NULL and DEFAULT clauses, but in reality, the variable was introduced for compatibility with MySQL, and MySQL documentation is quite specific about this:
The description shouldn't have had the "without a default value" note. It was meant to emphasize that it doesn't have DEFAULT current_timestamp(), but I see how it could have been misinterpreted. | ||
| Comment by Sergei Golubchik [ 2022-07-12 ] | ||
|
I'd prefer explicit_defaults_for_timestamp to mean that one needs to specify DEFAULT clause for TIMESTAMP columns explicitly, otherwise they'll have no default value. As such, it does not affect behavior on NULL in NOT NULL columns. One can even argue that it's a bug in MySQL that explicit_defaults_for_timestamp affects behavior completely unrelated to defaults. It should've been standard_timestamp or no_implicit_timestamp_magic or something. | ||
| Comment by Elena Stepanova [ 2022-07-12 ] | ||
|
One can argue (and more than one argued in the past) that the original idea of weird incomprehensible non-default timestamp behavior – all aspects of it – is a bug in MySQL, which wasn't easy to fix due to years of legacy, so the variable was introduced as a temporary measure to make the transition smoother. Introducing two different variables for this would have been clearly an overkill. |