Re: [HACKERS] create table and default 'now' problem ? - Mailing list pgsql-hackers

From Thomas Lockhart
Subject Re: [HACKERS] create table and default 'now' problem ?
Date
Msg-id 37E72573.4EB4C364@alumni.caltech.edu
Whole thread Raw
In response to Re: [HACKERS] create table and default 'now' problem ?  (The Hermit Hacker <scrappy@hub.org>)
List pgsql-hackers
> Why the 'create function'?
> hardware=> insert into test_table values ( 1 ) ;
> hardware=> select * from test_table;
> 1|Tue Sep 21 02:00:50 1999 EDT

Right. And if you run the insert again, you'll see the exact same time
inserted. But if you force 'now' to be a true string type (rather than
leaving it unspecified) then the evaluation will happen at insert
time.

The behavior is "correct" for most values of most types, but falls
down when a seemingly constant value, like a fixed string N-O-W,
actually is not a constant but rather something which changes value
depending on when the query runs. In the long run, we need to have a
new attribute associated with data types which tells whether constants
have that nature (most won't). In the meantime, this is a feature, and
has been since Vadim (?) implemented DEFAULT ;)
                       - Thomas

-- 
Thomas Lockhart                lockhart@alumni.caltech.edu
South Pasadena, California


pgsql-hackers by date:

Previous
From: José Soares
Date:
Subject: Re: [HACKERS] create table and default 'now' problem ?
Next
From: Tom Lane
Date:
Subject: Re: [HACKERS] create table and default 'now' problem ?