Re: Is it safe to use DEFAULT currval()

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

On Saturday 27 September 2003 18:40, Tom Lane wrote:
> 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.

I feared as much. Ah well, use nextval(), a different sequence or write a
trigger I suppose.

--
Richard Huxton
Archonet Ltd

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Relaxin 2003-09-27 18:16:07 ODBC will not be supported by Microsoft in the future
Previous Message Tom Lane 2003-09-27 17:40:40 Re: Is it safe to use DEFAULT currval()