Skip site navigation (1) Skip section navigation (2)

Re: [HACKERS] datetime default 'now' broken?

From: "Thomas G(dot) Lockhart" <lockhart(at)alumni(dot)caltech(dot)edu>
To: Brett McCormickS <brett(at)abraxas(dot)scene(dot)com>
Cc: pgsql-hackers(at)hub(dot)org
Subject: Re: [HACKERS] datetime default 'now' broken?
Date: 1998-03-16 05:59:53
Message-ID: 350CBFD9.FC04A5E9@alumni.caltech.edu (view raw or flat)
Thread:
Lists: 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

In response to

Responses

pgsql-hackers by date

Next:From: Thomas G. LockhartDate: 1998-03-16 06:04:11
Subject: Re: [HACKERS] Small changes for the "no excuses" release
Previous:From: Bruce MomjianDate: 1998-03-16 05:58:48
Subject: Re: [HACKERS] initdb and xpg_user

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group