Details
-
Type:
Task
-
Status: Closed (View Workflow)
-
Priority:
Critical
-
Resolution: Duplicate
-
Fix Version/s: N/A
-
Component/s: Data Manipulation - Update, Temporal Types
-
Labels:None
Description
I was going to report this bug:
CREATE TABLE t (
|
id INTEGER NOT NULL,
|
t1 TIMESTAMP NOT NULL,
|
t2 TIMESTAMP,
|
CONSTRAINT pk_t PRIMARY KEY (id)
|
);
|
|
INSERT INTO t (id, t1)
|
VALUES (1, timestamp '1970-01-01 01:00:38.0');
|
|
UPDATE t
|
SET
|
t.t2 = timestamp '1970-01-01 01:02:10.0';
|
|
SELECT * FROM t;
|
Clearly, I don't want the result to be what it currently is:
id | t1 | t2 |
1 | 2022-05-04 13:57:45.000 | 1970-01-01 01:02:10.000 |
It's so easy to achieve this behaviour if I wanted it by explicitly specifying the default. It's so hard to remember that this feature exists, having spent yet another 30 minutes debugging my own code until I was reminded of this:
https://mariadb.com/kb/en/timestamp/#automatic-values
It's very random, why would the first TIMESTAMP ever be special? Why not the last? Or the fifth? What about DATETIME, why doesn't it apply there?
I strongly suggest you remove this "feature," which looks like a bug to me every time I run into it, and it's really not the first time. Users can very easily specify DEFAULT expressions themselves
Attachments
Issue Links
- duplicates
-
MDEV-28632 Change default of explicit_defaults_for_timestamp to ON
-
- Closed
-