From: Tom Lane <tgl@sss.pgh.pa.us>
To: Spiegelberg, Greg <gspiegelberg@isodxsolutions.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: duplicate key violates unique constraint
Date: Thu, 10 May 2007 11:28:41 -0400
Message-ID: <13812.1178810921@sss.pgh.pa.us> (raw)
In-Reply-To: <82E74D266CB9B44390D3CCE44A781ED90B6B15@POSTOFFICE.cranel.local>
References: <82E74D266CB9B44390D3CCE44A781ED90B6B15@POSTOFFICE.cranel.local>
"Spiegelberg, Greg" <gspiegelberg@isodxsolutions.com> 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
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-admin@postgresql.org
Cc: tgl@sss.pgh.pa.us, gspiegelberg@isodxsolutions.com
Subject: Re: duplicate key violates unique constraint
In-Reply-To: <13812.1178810921@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