Re: [HACKERS] datetime default 'now' broken? - Mailing list pgsql-hackers

From Thomas G. Lockhart
Subject Re: [HACKERS] datetime default 'now' broken?
Date
Msg-id 350CBFD9.FC04A5E9@alumni.caltech.edu
Whole thread Raw
In response to datetime default 'now' broken?  (Brett McCormickS <brett@abraxas.scene.com>)
Responses Re: [HACKERS] datetime default 'now' broken?  ("Henry B. Hotz" <hotz@jpl.nasa.gov>)
List pgsql-hackers
> If I create a table with a datetime field with a default of 'now',
> every insert the value is the time of table creation instead of the
> time of insert, which is how it behaved in previous releases (I think
> this was even documented).

I can't recall it ever working that way, though before we discovered
that it didn't we all assumed that it _did_ work that way :)

The workaround is to define it as

  ... default datetime('now'::text)

which forces the string to be evaluated at runtime. The SQL symbol
CURRENT_TIMESTAMP also misbehaves in "default" clauses, and I'm
considering changing it a bit to get around the problem.

                 - Tom

pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [PATCHES] Re: [HACKERS] "Doubled" files related to cyrillic patch in 6.3 release.
Next
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] initdb and xpg_user