Re: [HACKERS] Bug: timestamp without time zone column allows timestamptz default - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [HACKERS] Bug: timestamp without time zone column allows timestamptz default
Date
Msg-id 5742.1489504921@sss.pgh.pa.us
Whole thread Raw
In response to [HACKERS] Bug: timestamp without time zone column allows timestamptz default  (David Fetter <david@fetter.org>)
List pgsql-hackers
David Fetter <david@fetter.org> writes:
>     CREATE TABLE bar(t TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP);

> This is a foot gun we need not have.

Yes, we do need to have it.

(1) if we remove the implicit cast from timestamptz to timestamp, the
villagers will be on our doorsteps with the usual equipment.  I'm still
hearing bitching about the 8.3 implicit-cast-ectomy, which took away
only casts far less defensible than this one.

(2) you have not actually demonstrated an unacceptable consequence
of the above coding.  I will grant that using "localtimestamp" is
a cleaner and more efficient approach, but:

regression=# create table tt (f1 timestamp default current_timestamp,
regression(# f2 timestamp default localtimestamp);
CREATE TABLE
regression=# insert into tt default values;
INSERT 0 1
regression=# table tt;           f1             |            f2
---------------------------+---------------------------2017-03-14 11:13:31.78774 | 2017-03-14 11:13:31.78774
(1 row)

Looks to me like you get the same results after zone rotation happens.
(The same is true when the column type is timestamptz, btw.)
        regards, tom lane



pgsql-hackers by date:

Previous
From: David Fetter
Date:
Subject: [HACKERS] Bug: timestamp without time zone column allows timestamptz default
Next
From: Anastasia Lubennikova
Date:
Subject: Re: [HACKERS] Backend crash on non-exclusive backup cancel