Re: duplicate key violates unique constraint - Mailing list pgsql-admin

From Spiegelberg, Greg
Subject Re: duplicate key violates unique constraint
Date
Msg-id 82E74D266CB9B44390D3CCE44A781ED90B6B1A@POSTOFFICE.cranel.local
Whole thread Raw
In response to Re: duplicate key violates unique constraint  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-admin
> From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
>
> "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?

I have to assume that though I don't see it anywhere in the logs and the
logs are turned up all the way.  The database is continually being
dropped and recreated automatically.  Why this doesn't happen every time
the same data is imported or more often is leaving me scratching my
head.


> 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.

Thanks.  That does explain it.  I had incorrectly assumed currval()
always returned what the real current value of the sequence.

pgsql-admin by date:

Previous
From: Carol Walter
Date:
Subject: Re: duplicate key violates unique constraint
Next
From: "Sorin N. Ciolofan"
Date:
Subject: increasing of the shared memory does not solve the problem of "OUT of shared memory"