Re: Sequences, values still increased - Mailing list pgsql-sql

From Chris Browne
Subject Re: Sequences, values still increased
Date
Msg-id 60psg1ahhy.fsf@dba2.int.libertyrms.com
Whole thread Raw
List pgsql-sql
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.


pgsql-sql by date:

Previous
From: "sathish kumar shanmugavelu"
Date:
Subject: User Permission
Next
From: Tom Lane
Date:
Subject: Re: INSERT/UPDATEs cycles and lack of phantom locking