Re: TIMESTAMP WITH( OUT)? TIME ZONE indexing/type choice... - Mailing list pgsql-general

From Tom Lane
Subject Re: TIMESTAMP WITH( OUT)? TIME ZONE indexing/type choice...
Date
Msg-id 21092.1045545421@sss.pgh.pa.us
Whole thread Raw
In response to Re: TIMESTAMP WITH( OUT)? TIME ZONE indexing/type choice...  (Sean Chittenden <sean@chittenden.org>)
List pgsql-general
Sean Chittenden <sean@chittenden.org> writes:
> iirc, you have to put quotes around CURRENT_TIMESTAMP otherwise the
> default value is set to the CURRENT_TIMESTAMP at this very instant
> instead of being evaluated at runtime when a record is inserted.  -sc

Not so --- CURRENT_TIMESTAMP is a function, not a literal, despite the
lack of parentheses (you can blame the SQL spec for that weirdness).
It will in fact *not* work when quoted.

I think you are thinking of now() --- now() is a function, 'now' is
an acceptable timestamp literal, but the latter is generally a bad
choice for a column default because of the time-of-evaluation issue.

            regards, tom lane

pgsql-general by date:

Previous
From: Dennis Gearon
Date:
Subject: Re: TIMESTAMP WITH( OUT)? TIME ZONE indexing/type choice...
Next
From: Martijn van Oosterhout
Date:
Subject: Re: Index not used with IS NULL