Re: VALUES() evaluation order

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Steve Atkins <steve(at)blighty(dot)com>
Cc: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: VALUES() evaluation order
Date: 2013-01-13 22:36:42
Message-ID: 257.1358116602@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox
Thread:
Lists: pgsql-general

Steve Atkins <steve(at)blighty(dot)com> writes:
> Is the order in which the expressions in a VALUES() clause defined?
> I'm doing this: INSERT INTO foo (a, b) VALUES (nextval('bar'), currval('bar'))

> It works fine, but I'm wondering whether it's guaranteed to work or whether I'm relying on an artifact of the implementation.

I'd say it's an artifact. It probably does work reliably at the moment,
but if we had a reason to change it we'd not feel much compunction about
doing so. (The most obvious potential reason to change it is parallel
evaluation of expressions, which is a long way off, so you probably
don't have any near-term reason to worry. But ...)

Consider sticking the nextval() into a WITH.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gavin Flower 2013-01-13 22:44:42 Re: Linux Distribution Preferences?
Previous Message Steve Atkins 2013-01-13 22:19:25 VALUES() evaluation order