BUG #1083: Insert query reordering interacts badly with NEXTVAL()/CURRVAL()

From: "PostgreSQL Bugs List" <pgsql-bugs(at)postgresql(dot)org>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #1083: Insert query reordering interacts badly with NEXTVAL()/CURRVAL()
Date: 2004-02-24 01:26:57
Message-ID: 20040224012657.B86E5CF4A21@www.postgresql.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-sql


The following bug has been logged online:

Bug reference: 1083
Logged by: Martin Langhoff

Email address: martin(at)catalyst(dot)net(dot)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

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2004-02-24 01:49:10 Re: Crash when calling a pl/pgsql function with no row to pass as an argument
Previous Message Michael Meskes 2004-02-23 18:15:29 Re: ecpg mapping struct members for indicators incorrectly?

Browse pgsql-sql by date

  From Date Subject
Next Message Bruno Wolff III 2004-02-24 02:11:17 Re: BUG #1083: Insert query reordering interacts badly with NEXTVAL()/CURRVAL()
Previous Message jbduffy 2004-02-23 13:21:32 plpgsql function returning SETOF RECORD Question