Re: Sequences, values still increased

Поиск
Список
Период
Сортировка
От Chris Browne
Тема Re: Sequences, values still increased
Дата
Msg-id 60psg1ahhy.fsf@dba2.int.libertyrms.com
обсуждение исходный текст
Список 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 по дате отправления:

Предыдущее
От: "sathish kumar shanmugavelu"
Дата:
Сообщение: User Permission
Следующее
От: Tom Lane
Дата:
Сообщение: Re: INSERT/UPDATEs cycles and lack of phantom locking