X-Original-To: pgsql-bugs-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 3192DD1BAA2 for ; Tue, 24 Feb 2004 05:37:55 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 92301-02 for ; Tue, 24 Feb 2004 01:37:53 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id BD667D1BAC2 for ; Tue, 24 Feb 2004 01:37:51 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i1O5bm27018401; Tue, 24 Feb 2004 00:37:48 -0500 (EST) To: martin@catalyst.net.nz Cc: "PostgreSQL Bugs List" Subject: Re: BUG #1083: Insert query reordering interacts badly with NEXTVAL()/CURRVAL() In-reply-to: <20040224012657.B86E5CF4A21@www.postgresql.com> References: <20040224012657.B86E5CF4A21@www.postgresql.com> Comments: In-reply-to "PostgreSQL Bugs List" message dated "Mon, 23 Feb 2004 21:26:57 -0400" Date: Tue, 24 Feb 2004 00:37:47 -0500 Message-ID: <18400.1077601067@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/118 X-Sequence-Number: 7906 "PostgreSQL Bugs List" 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