X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id A624A9FA4A7 for ; Wed, 19 Jul 2006 10:04:15 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 57131-09 for ; Wed, 19 Jul 2006 13:04:06 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) by postgresql.org (Postfix) with ESMTP id E946E9FA47F for ; Wed, 19 Jul 2006 10:04:05 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 320E730B99; Wed, 19 Jul 2006 15:04:03 +0200 (MET DST) From: Chris Browne X-Newsgroups: pgsql.sql Subject: Re: Sequences, values still increased Date: Wed, 19 Jul 2006 08:47:37 -0400 Organization: cbbrowne Computing Inc Lines: 33 Message-ID: <60psg1ahhy.fsf@dba2.int.libertyrms.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@news.hub.org User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4.19 (linux) Cancel-Lock: sha1:6NyZ8zCFnfdXMMBuxrlg0v5kRoE= To: pgsql-sql@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200607/247 X-Sequence-Number: 25821 Paul Maier writes: > Hello everybody, > > Why does... > > BEGIN; > SELECT nextval('test.test_seq') AS id; > ROLLBACK; > > ...still increase the sequence after aborting the transaction? This > nextval-command should be reverted after rolling back, right? Same with an > ABORT: > > BEGIN; > SELECT nextval('test.test_seq') AS id; > ABORT; > > Can anybody help me with this? Thanks a lot! nextval does NOT roll back. As per the Fine Documentation on Sequence Manipulation Functions: "Important: To avoid blocking of concurrent transactions that obtain numbers from the same sequence, a nextval operation is never rolled back; that is, once a value has been fetched it is considered used, even if the transaction that did the nextval later aborts. This means that aborted transactions may leave unused "holes" in the sequence of assigned values. setval operations are never rolled back, either." -- output = ("cbbrowne" "@" "ntlug.org") http://cbbrowne.com/info/lsf.html I'm as confused as a baby in a topless bar.