Re: Bug? - Mailing list pgsql-general

From Doug McNaught
Subject Re: Bug?
Date
Msg-id m3n11nbp4n.fsf@belphigor.mcnaught.org
Whole thread Raw
In response to Bug?  (Rasmus Resen Amossen <NOSPAM@hey.com>)
List pgsql-general
"Andrew G. Hammond" <drew@xyzzy.dhs.org> writes:

> Is this correct behaviour?  ACID compliant?  The argument in it's favour it
> pretty obvious: if you never go backwards then you'll never get an accidental
> duplication as follows:
>
> t1 BEGIN; SELECT nextval('test_id_seq')    # 1
> t2 SELECT nextval('test_id_seq')        # 2
> t1 ROLLBACK                 # test_id_seq decremented
> t3 SELECT nextval('test_id_seq')        # 2
>
> However wouldn't locking the sequence be more proper behaviour?

As I understand it, this is one case where efficiency wins out--if you
locked the sequence some apps could end up with a lot of lock
contention.  So we don't lock, don't roll back and work fine except
that there can be gaps in a SERIAL column.

I don't think sequences are in the SQL standard so we're not really
violating anything.  ;)

-Doug
--
Let us cross over the river, and rest under the shade of the trees.
   --T. J. Jackson, 1863

pgsql-general by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: Bug?
Next
From: Francisco Reyes
Date:
Subject: Re: pgsql and large tables