Re: Sequences change in a rolled-back transactions - Mailing list pgsql-general

From Alvaro Herrera
Subject Re: Sequences change in a rolled-back transactions
Date
Msg-id 20090309152555.GF12932@alvh.no-ip.org
Whole thread Raw
In response to Sequences change in a rolled-back transactions  (Erwin Moller <erwin@darwine.nl>)
Responses Re: Sequences change in a rolled-back transactions  (Erwin Moller <erwin@darwine.nl>)
Re: Sequences change in a rolled-back transactions  (Craig Ringer <craig@postnewspapers.com.au>)
List pgsql-general
Erwin Moller wrote:

> I thought a transaction that is rolled back, rolls back *everything*
> done in that transaction.
> Appearantly sequences are not included.

Yes.  This is actually a desirable property, because it allows sequences
to work fine in concurrent scenarios (which are, after all, the whole
point of sequences).

If you actually need an incremental number with no gaps (which is rare
but not unseen), you need to use some other mechanism, which will
probably involve a lock to prevent concurrency.

--
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

pgsql-general by date:

Previous
From: Erwin Moller
Date:
Subject: Sequences change in a rolled-back transactions
Next
From: Erwin Moller
Date:
Subject: Re: Sequences change in a rolled-back transactions