Re: Locking to restrict rowcounts. - Mailing list pgsql-general

From Glen Parker
Subject Re: Locking to restrict rowcounts.
Date
Msg-id 4A130807.5030703@nwlink.com
Whole thread Raw
In response to Re: Locking to restrict rowcounts.  (Richard Huxton <dev@archonet.com>)
List pgsql-general
Richard Huxton wrote:
> Glen Parker wrote:
>> Richard Huxton wrote:
>>
>> #3 won't work unless the other transactions have all committed by the
>> time you do the check.  It is guaranteed to fail at some point.
>
> If it's in an AFTER INSERT/UPDATE trigger then whatever transaction
> takes you beyond 10 rows you will always get a failure. If you get a lot
> of insert/delete pairings then you could spend a lot of time counting
> rows, but that's all.


I still don't think it will work.  Two concurrent transactions could
still screw the data up.

Before: 9 rows.
Tx 1: See 9 rows, issue insert, see 10 rows.
Tx 2: See 9 rows, issue insert, see 10 rows.
After: 11 rows.

-Glen


pgsql-general by date:

Previous
From: Glen Parker
Date:
Subject: Re: Locking to restrict rowcounts.
Next
From: Andy Colson
Date:
Subject: Re: origins/destinations