Re: Is it safe to use DEFAULT currval()

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Richard Huxton <dev(at)archonet(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Is it safe to use DEFAULT currval()
Date: 2003-09-27 17:40:40
Message-ID: 6626.1064684440@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Richard Huxton <dev(at)archonet(dot)com> writes:
> CREATE TABLE foo (
> id SERIAL,
> blah text,
> tracking int4 DEFAULT currval('foo_id_seq')
> PRIMARY KEY (id)
> );

> Now - it works, but is that a design feature or just luck?

You're essentially assuming that the column expressions for an INSERT
will be evaluated left-to-right. That's true at the moment, and I don't
see any foreseeable reason why we'd change it, but it surely is an
implementation dependency that could bite you someday.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2003-09-27 17:47:51 Re: Is it safe to use DEFAULT currval()
Previous Message Tom Lane 2003-09-27 17:33:16 Re: initdb failure (was Re: [GENERAL] sequence's plpgsql)