pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: "D'Arcy" "J.M." Cain <darcy@druid.net>
To: kyle@actarg.com
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] begin/end/abort work for sequences?
Date: Thu, 1 Jul 1999 12:26:59 -0400 (EDT)
Message-ID: <m10zjfv-0000bFC@druid.net> (raw)
In-Reply-To: <377B7A2F.26209427@actarg.com>

Thus spake Kyle Bateman
> Do you know if there is a workaround?  In my particular situation, it is critical
> that all instances of the sequence actually get used.  If a transaction is
> aborted, I lose an instance and everything gets messed up.

I had to solve this once in another RDBMS (Progress) and this is how I
did it.  I had a table of available sequence numbers consisting of two
fields, a name and a number.  The table was seeded with 10 entries for
each required sequence numbered 1 to 10.  When I needed a sequence I
started a transaction and grabbed and locked the lowest numbered record
for that sequence that wasn't locked.  I save the number then add 10 to
it.  If I abort the transaction, the number remains unchanged.  Under
this scheme 10 users can be working on the same sequence without locking
others out.  Numbers can be used out of sequence from time to time if
someone aborts but they all get used eventually.

-- 
D'Arcy J.M. Cain <darcy@{druid|vex}.net>   |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 424 2871     (DoD#0082)    (eNTP)   |  what's for dinner.



view thread (7+ messages)  latest in thread

Message-ID: <m10zjfv-0000bFC@druid.net>
Permalink:  ../m10zjfv-0000bFC@druid.net/
Also on:    postgresql.org/message-id/m10zjfv-0000bFC@druid.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: darcy@druid.net, kyle@actarg.com
  Subject: Re: [SQL] begin/end/abort work for sequences?
  In-Reply-To: <m10zjfv-0000bFC@druid.net>
  References: <377B7A2F.26209427@actarg.com> <m10zjfv-0000bFC@druid.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox