pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Chris Browne <cbbrowne@acm.org>
To: pgsql-sql@postgresql.org
Subject: Re: Sequences, values still increased
Date: Wed, 19 Jul 2006 08:47:37 -0400
Message-ID: <60psg1ahhy.fsf@dba2.int.libertyrms.com> (raw)
References: <e9l4as$2bok$1@news.hub.org>

Paul Maier <paul.meier@t-online.de> 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.



Message-ID: <60psg1ahhy.fsf@dba2.int.libertyrms.com>
Permalink:  ../60psg1ahhy.fsf@dba2.int.libertyrms.com/
Also on:    postgresql.org/message-id/60psg1ahhy.fsf@dba2.int.libertyrms.com

 · 

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: cbbrowne@acm.org
  Subject: Re: Sequences, values still increased
  In-Reply-To: <60psg1ahhy.fsf@dba2.int.libertyrms.com>

* 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