Re: target list evaluation wrt sequences

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruno Wolff III <bruno(at)wolff(dot)to>
Cc: pgsql-general(at)postgresql(dot)org, elein(at)varlena(dot)com
Subject: Re: target list evaluation wrt sequences
Date: 2004-04-30 05:01:25
Message-ID: 20921.1083301285@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> elein <elein(at)varlena(dot)com> wrote:
>> Is the order of the target list guaranteed?

AFAIR, all current and past Postgres versions evaluate target lists
left-to-right. This is not guaranteed to remain true forever,
since neither the SQL spec nor our own docs promise it anywhere...
but offhand I can't think of a reason to break it.

Bruno Wolff III <bruno(at)wolff(dot)to> writes:
> No. You can do effectively this by joining a select nextval to whatever
> you main select is. Something like:
> insert into ...
> select a.n as a, a.n as b, ....
> from (select nextval('n') as n) as a, lalala

Urgh ... I'd not want to promise that nextval() will always be evaluated
just once in the above example ... this really seems *much* more fragile
than assuming left-to-right targetlist evaluation :-(

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gregory S. Williamson 2004-04-30 08:14:38 Re: "Idle in Transaction" and hung connections
Previous Message Tom Lane 2004-04-30 04:34:39 Re: TCP only listening on localhost???