Re: Summary table trigger example race condition

From: Mark Kirkwood <markir(at)paradise(dot)net(dot)nz>
To: Mark Kirkwood <markir(at)paradise(dot)net(dot)nz>
Cc: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>, pgsql-patches(at)postgresql(dot)org, pgsql-docs(at)postgresql(dot)org
Subject: Re: Summary table trigger example race condition
Date: 2006-01-11 02:18:49
Message-ID: 43C46B09.8080300@paradise.net.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs pgsql-patches

Mark Kirkwood wrote:
> Jim C. Nasby wrote:
>
>> On Sun, Jan 08, 2006 at 04:13:01PM +1300, Mark Kirkwood wrote:
>>
>>
>>
>> What happens if someone deletes the row between the failed insert and
>> the second update? :)
>>
>
> In this example the rows in the summary table never get deleted by
> DELETE operations on that main one - the trigger just decrements the
> various amounts - i.e DELETE becomes UPDATE, so no problem there.
>

Sorry Jim, I just realized you probably meant someone directly deleting
rows in the summary table itself. Well yes, that would certainly fox it!

I guess I was implicitly considering a use case where the only direct
DML on the summary table would be some sort of ETL process, which would
probably lock out other changes (and re-create the summary table data
afterwards in all likelihood).

Cheers

Mark

In response to

Browse pgsql-docs by date

  From Date Subject
Next Message Alvaro Herrera 2006-01-11 22:35:42 Re: [PATCHES] Summary table trigger example race condition
Previous Message Mark Kirkwood 2006-01-11 00:40:37 Re: Summary table trigger example race condition

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2006-01-11 03:44:39 Re: TODO-item: Add sleep() function, remove from regress.c
Previous Message Andrew Dunstan 2006-01-11 01:02:39 Re: TODO-item: Add sleep() function, remove from regress.c