Re: Sequences change in a rolled-back transactions

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Erwin Moller <erwin(at)darwine(dot)nl>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Sequences change in a rolled-back transactions
Date: 2009-03-09 15:25:55
Message-ID: 20090309152555.GF12932@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Erwin Moller 2009-03-09 15:40:14 Re: Sequences change in a rolled-back transactions
Previous Message justin 2009-03-09 15:15:40 Re: mdf