pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: martin@catalyst.net.nz
Cc: PostgreSQL Bugs List <pgsql-bugs@postgresql.org>
Subject: Re: BUG #1083: Insert query reordering interacts badly with NEXTVAL()/CURRVAL()
Date: Tue, 24 Feb 2004 00:37:47 -0500
Message-ID: <18400.1077601067@sss.pgh.pa.us> (raw)
In-Reply-To: <20040224012657.B86E5CF4A21@www.postgresql.com>
References: <20040224012657.B86E5CF4A21@www.postgresql.com>

"PostgreSQL Bugs List" <pgsql-bugs@postgresql.org> writes:
> /* this statement will reverse the order of CURRVAL()/NEXTVAL() to match the 
> column order of the table */ 
> INSERT INTO testing (col_b, col_a) VALUES (NEXTVAL('seq'), CURRVAL('seq'));

This is not a bug.  The order of evaluation of select-lists and
values-lists is not defined anywhere in the SQL standard, nor promised
anywhere in the Postgres documentation.  In fact, we specifically say
here:
http://www.postgresql.org/docs/7.4/static/sql-expressions.html#SYNTAX-EXPRESS-EVAL
that "The order of evaluation of subexpressions is not defined."  To do
otherwise would put horrible crimps in our ability to optimize query plans.

			regards, tom lane



view thread (7+ messages)  latest in thread

Message-ID: <18400.1077601067@sss.pgh.pa.us>
Permalink:  ../18400.1077601067@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/18400.1077601067@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, martin@catalyst.net.nz, pgsql-bugs@postgresql.org
  Subject: Re: BUG #1083: Insert query reordering interacts badly with NEXTVAL()/CURRVAL()
  In-Reply-To: <18400.1077601067@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox