Re: Problems with sequences - Mailing list pgsql-general

From Arturo Perez
Subject Re: Problems with sequences
Date
Msg-id D46CA628-E48E-477C-81DB-376FB3368AF2@hayesinc.com
Whole thread Raw
In response to Re: Problems with sequences  ("Merlin Moncure" <mmoncure@gmail.com>)
Responses Re: Problems with sequences  ("Merlin Moncure" <mmoncure@gmail.com>)
List pgsql-general
On Sep 6, 2006, at 8:48 PM, Merlin Moncure wrote:

> On 9/6/06, Arturo Perez <aperez@hayesinc.com> wrote:
>> What happens is that if I do a select nextval('seq') I get a number
>> that's lower than the
>> max primary key id.  This is inspite of my doing
>>    SELECT setval('seq', ((SELECT MAX(seq_ID) FROM table)+1))
>>    ALTER SEQUENCE seq RESTART WITH <max + 1>;
>>    select pg_catalog.setval(seq, <max+1>, true);
>>
>
> are you running those statements to fetch the next key in the table?
> you might have a race condition there.  try wrappnig in a userlock.
>
> merlin

No, not running them to get the next key.  Just trying to reset the
sequence so that I stop getting duplicates.

A race condition is unlikely as only one person can actually add
these things to the system.

-arturo


pgsql-general by date:

Previous
From: Stephen Frost
Date:
Subject: Re: On DNS for postgresql.org
Next
From: "Joshua D. Drake"
Date:
Subject: Re: On DNS for postgresql.org