From: | "chris smith" <dmagick(at)gmail(dot)com> |
---|---|
To: | "Jorge Godoy" <jgodoy(at)gmail(dot)com> |
Cc: | "PostgreSQL General ML" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Best approach for a "gap-less" sequence |
Date: | 2006-08-12 13:24:46 |
Message-ID: | 3c1395330608120624s2902adb9k2fbab19b3f2979e8@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 8/12/06, Jorge Godoy <jgodoy(at)gmail(dot)com> wrote:
>
> Hi!
>
>
> I was trying to solve a problem on an old system and realized that there might
> be some better approach for doing what I need.
>
> We have some documents that need to be ordered sequentially and without gaps.
> I could use a sequence, but if the transaction fails then when I rollback the
> sequence will already have been incremented.
>
> So, today I have a control table and I acquire a SHARE ROW EXCLUSIVE lock to
> it, read the value, increase it, do what I need and then I COMMIT the
> transaction, ensuring that the sequence has no gaps.
>
> Is there a better way to guarantee that there will be no gaps in my sequence
> if something goes wrong with my transaction?
Why does it matter?
I assume there is a reason you need it like this..
--
Postgresql & php tutorials
http://www.designmagick.com/
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Kellerer | 2006-08-12 13:29:03 | Re: Best approach for a "gap-less" sequence |
Previous Message | Martijn van Oosterhout | 2006-08-12 11:35:21 | Re: read only transaction, temporary tables |