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 333F8D1DF80 for ; Tue, 24 Feb 2004 01:26:59 +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 20032-09 for ; Mon, 23 Feb 2004 21:27:01 -0400 (AST) Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) by svr1.postgresql.org (Postfix) with ESMTP id D2418D1DF7F for ; Mon, 23 Feb 2004 21:26:57 -0400 (AST) Received: by www.postgresql.com (Postfix, from userid 80) id B86E5CF4A21; Mon, 23 Feb 2004 21:26:57 -0400 (AST) To: pgsql-bugs@postgresql.org Subject: BUG #1083: Insert query reordering interacts badly with NEXTVAL()/CURRVAL() From: "PostgreSQL Bugs List" Message-Id: <20040224012657.B86E5CF4A21@www.postgresql.com> Date: Mon, 23 Feb 2004 21:26:57 -0400 (AST) X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/115 X-Sequence-Number: 7903 The following bug has been logged online: Bug reference: 1083 Logged by: Martin Langhoff Email address: martin@catalyst.net.nz PostgreSQL version: 7.4 Operating system: Linux irkutsk 2.4.25-piv-smp-server #1 SMP Fri Feb 20 16:56:47 NZDT 2004 i686 unknown Description: Insert query reordering interacts badly with NEXTVAL()/CURRVAL() Details: === SQL === CREATE TEMP TABLE testing (col_a integer, col_b integer); CREATE TEMP SEQUENCE seq; /* this statement will produce the expected result */ INSERT INTO testing (col_a, col_b) VALUES (NEXTVAL('seq'), CURRVAL('seq')); /* 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')); SELECT * FROM testing; === END SQL === Output looks like: col_a | col_b -------+------- 1 | 1 1 | 2 I was expecting: col_a | col_b -------+------- 1 | 1 2 | 2