pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jeffrey Tenny <jeffrey.tenny@comcast.net>
To: pgsql-sql@postgresql.org
Subject: Atomic query and update of sequence generators
Date: Wed, 14 Jan 2004 19:51:49 -0500
Message-ID: <4005E425.2070706@comcast.net> (raw)


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.












view thread (3+ messages)  latest in thread

Message-ID: <4005E425.2070706@comcast.net>
Permalink:  ../4005E425.2070706@comcast.net/
Also on:    postgresql.org/message-id/4005E425.2070706@comcast.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: jeffrey.tenny@comcast.net
  Subject: Re: Atomic query and update of sequence generators
  In-Reply-To: <4005E425.2070706@comcast.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox