Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id CB7BE9FBA1E for ; Thu, 10 May 2007 12:28:50 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 90071-01 for ; Thu, 10 May 2007 12:28:43 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id DFDB49FB453 for ; Thu, 10 May 2007 12:28:43 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.1/8.14.1) with ESMTP id l4AFSguF013813; Thu, 10 May 2007 11:28:42 -0400 (EDT) To: "Spiegelberg, Greg" cc: pgsql-admin@postgresql.org Subject: Re: duplicate key violates unique constraint In-reply-to: <82E74D266CB9B44390D3CCE44A781ED90B6B15@POSTOFFICE.cranel.local> References: <82E74D266CB9B44390D3CCE44A781ED90B6B15@POSTOFFICE.cranel.local> Comments: In-reply-to "Spiegelberg, Greg" message dated "Thu, 10 May 2007 09:38:25 -0400" Date: Thu, 10 May 2007 11:28:41 -0400 Message-ID: <13812.1178810921@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/86 X-Sequence-Number: 25406 "Spiegelberg, Greg" writes: > As you can see, it's only providing the key1 column and the sequence is > providing the value for the column with the constraint. How can this be > happening? Perhaps at some point you manually inserted an id value past the then-current sequence value? > Now, I don't know if this just hasn't been tested or is a documented > feature (a.k.a. bug) but something does not seem right here. In this > test case I'm able to get the same sequence ID's via two psql > connections to the same database on the same sequence. No, you've misunderstood currval(). That gives the value most recently obtained by nextval() within your own session; it is not affected by any subsequent manipulation of the sequence. regards, tom lane