Re: duplicate key violates unique constraint

From: "Spiegelberg, Greg" <gspiegelberg(at)isodxsolutions(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <pgsql-admin(at)postgresql(dot)org>
Subject: Re: duplicate key violates unique constraint
Date: 2007-05-11 13:33:22
Message-ID: 82E74D266CB9B44390D3CCE44A781ED90B6B1A@POSTOFFICE.cranel.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

> From: Tom Lane [mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us]
>
> "Spiegelberg, Greg" <gspiegelberg(at)isodxsolutions(dot)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.

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Sorin N. Ciolofan 2007-05-11 13:58:28 increasing of the shared memory does not solve the problem of "OUT of shared memory"
Previous Message Carol Walter 2007-05-11 13:23:38 Re: duplicate key violates unique constraint