Re: Problems with sequences

From: "Merlin Moncure" <mmoncure(at)gmail(dot)com>
To: "Arturo Perez" <aperez(at)hayesinc(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Problems with sequences
Date: 2006-09-07 00:48:17
Message-ID: b42b73150609061748vfe778d4h2265ae9ce95f9848@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 9/6/06, Arturo Perez <aperez(at)hayesinc(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tim Allen 2006-09-07 00:58:19 Re: On DNS for postgresql.org
Previous Message Steve Atkins 2006-09-07 00:34:07 Re: On DNS for postgresql.org