Re: pgsql-server/src backend/catalog/heap.c backen ...

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au>
Cc: pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql-server/src backend/catalog/heap.c backen ...
Date: 2003-07-30 14:37:23
Message-ID: 9669.1059575843@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

"Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au> writes:
>> Log message:
>> Coerce unknown-literal-constant default values to the column type during
>> CREATE TABLE (or ALTER TABLE SET DEFAULT), rather than postponing it to
>> the time that the default is inserted into an INSERT command by the
>> rewriter. This reverses an old decision that was intended to make the
>> world safe for writing
>> f1 timestamp default 'now'

> Does that mean that default current_timestamp will work?

It did, still does, and always will ;-). The case that we are no longer
supporting is with the simple unknown-literal-string-constant 'now'.
In 7.3 and before you could do this:

regression=# create table foo (
regression(# f1 timestamp default 'now',
regression(# f2 timestamp default timestamp 'now');
CREATE TABLE

and the first case would do what you were expecting (at least until you
got into prepared statements or plpgsql functions). The second case
would freeze the timestamp too soon, and was documented that way:

regression=# \d foo
Table "public.foo"
Column | Type | Modifiers
--------+-----------------------------+-------------------------------------------------------------------
f1 | timestamp without time zone | default 'now'
f2 | timestamp without time zone | default '2003-07-30 10:32:24.762288'::timestamp without time zone

regression=#

As of CVS tip, both cases work alike, namely the timestamp is frozen at
CREATE TABLE.

regards, tom lane

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2003-07-30 17:08:50 pgsql-server/src/test/regress pg_regress.sh
Previous Message Christopher Kings-Lynne 2003-07-30 01:46:16 Re: pgsql-server/src backend/catalog/heap.c backen ...