Skip site navigation (1) Skip section navigation (2)

Re: Issue with sequence and transactions

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Ian Meyer <misc(at)crewcial(dot)org>
Cc: PostgreSQL novice list <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Issue with sequence and transactions
Date: 2004-11-09 03:44:29
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
On Mon, Nov 08, 2004 at 22:27:39 -0500,
  Ian Meyer <misc(at)crewcial(dot)org> wrote:
> Why does the sequence not get rolled back? I have looked in 
> documentation, read endlessly in a PostgreSQL book and can't figure out 
> if that is the expected behavior.. and if so, why?

By not having the value of a sequence rolled back on transaction failure,
applications using sequences run faster under load.

> What I want to happen (at least, the way I see it happening) is if 
> someone creates a username, but the query fails, or the username is 
> taken already, then the transaction is rolled back, and the id that 
> would have been taken, is still free.

Then you probably don't want to use a sequence. Sequences should be used
to obtain unique values, not to generate a list of id numbers without

In response to

pgsql-novice by date

Next:From: graemeDate: 2004-11-09 09:36:01
Subject: Getting a trigger to call a function...
Previous:From: Ian MeyerDate: 2004-11-09 03:27:39
Subject: Issue with sequence and transactions

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group