Re: BUG #13507: INSERT into tables with SERIAL primary keys failing about half of the time - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #13507: INSERT into tables with SERIAL primary keys failing about half of the time
Date
Msg-id 28061.1437486045@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #13507: INSERT into tables with SERIAL primary keys failing about half of the time  (John R Pierce <pierce@hogranch.com>)
List pgsql-bugs
John R Pierce <pierce@hogranch.com> writes:
> On 7/20/2015 5:39 PM, dsrich@dsrich.net wrote:
>> This query (and three other versions  using DEFAULT and 'RETURNING payeenum'
>> clauses) fails about half the time with payees_pkey constraint violation.

> when you create a column of pseudotype SERIAL, it creates a SEQUENCE.

Yeah.  Have you checked whether the last_value of the sequence is above
the maximum value in the payeenum column?  It's not terribly hard to get
that out-of-sync, unfortunately, typically by loading data with
predetermined serial values.

The sequence is probably named payees_payeenum_seq, but psql's \d on
the payees table would show you for sure.

            regards, tom lane

pgsql-bugs by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: [HACKERS] object_classes array is broken, again
Next
From: Fabien COELHO
Date:
Subject: Re: BUG #13442: ISBN doesn't always roundtrip with text