Atomic query and update of sequence generators - Mailing list pgsql-sql

From Jeffrey Tenny
Subject Atomic query and update of sequence generators
Date
Msg-id 4005E425.2070706@comcast.net
Whole thread Raw
Responses Re: Atomic query and update of sequence generators
Re: Atomic query and update of sequence generators
List pgsql-sql
If I want to allocate a block of adjacent values from a sequence generator,
is the following statement atomic with respect to the time between
when the call to nextval() and setval()?

SELECT setval('foo', nextval()+20) ...

The goal is to get a sequence of 20 values that are all +1 from each other.

If the above isn't safe in concurrent environments, is there something 
else I can
do to achieve the effect safely?

I saw a similar unanswered question on one of the PostgreSQL newsgroups,
and have a need to do the same thing from my JDBC app.

Tips appreciated.











pgsql-sql by date:

Previous
From: A E
Date:
Subject: REPOST[GENERAL] Quoting for a Select Into - Please Help
Next
From: Stuart Barbee
Date:
Subject: Re: REPOST[GENERAL] Quoting for a Select Into - Please Help