John R Pierce <pierce(at)hogranch(dot)com> writes:
> On 7/20/2015 5:39 PM, dsrich(at)dsrich(dot)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