X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 96EF8D1D876 for ; Thu, 15 Jan 2004 00:52:19 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 77512-10 for ; Wed, 14 Jan 2004 20:51:51 -0400 (AST) Received: from rwcrmhc11.comcast.net (rwcrmhc11.comcast.net [204.127.198.35]) by svr1.postgresql.org (Postfix) with ESMTP id 94920D1D82F for ; Wed, 14 Jan 2004 20:51:47 -0400 (AST) Received: from comcast.net (dtenny.ne.client2.attbi.com[24.60.112.224]) by comcast.net (rwcrmhc11) with SMTP id <20040115005150013008iqfie>; Thu, 15 Jan 2004 00:51:50 +0000 Message-ID: <4005E425.2070706@comcast.net> Date: Wed, 14 Jan 2004 19:51:49 -0500 From: Jeffrey Tenny User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Atomic query and update of sequence generators Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/125 X-Sequence-Number: 16518 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.