Re: [SQL] begin/end/abort work for sequences? - Mailing list pgsql-sql

From Bruce Momjian
Subject Re: [SQL] begin/end/abort work for sequences?
Date
Msg-id 199907011530.LAA02443@candle.pha.pa.us
Whole thread Raw
In response to Re: [SQL] begin/end/abort work for sequences?  (Kyle Bateman <kyle@actarg.com>)
List pgsql-sql
> > If we rolled back sequence numbers, we would have to lock the table
> > until the transaction commited or was rolled back.  That is too much
> > locking so was not worth it.
> >
> 
> That seems like a pretty big thing to sacrifice.  Did sequence locking work before
> 6.5?  It was my impression that it did.

No, sequence numbers of aborted transactions never were saved.

> 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 recommend hand-rolling a sequence number, similar to how the sequence
mechanism works, but explicitly lock your sequence table, retrieve the
value, and the commit/abort will unlock the table.

--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


pgsql-sql by date:

Previous
From: Kyle Bateman
Date:
Subject: Re: [SQL] begin/end/abort work for sequences?
Next
From: "D'Arcy" "J.M." Cain
Date:
Subject: Re: [SQL] begin/end/abort work for sequences?