Re: SQL design pattern for a delta trigger?

From: Colin Wetherbee <cww(at)denterprises(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: SQL design pattern for a delta trigger?
Date: 2007-12-11 05:04:36
Message-ID: 475E1A64.5030000@denterprises.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Vivek Khera wrote:
> On Dec 10, 2007, at 5:04 PM, Colin Wetherbee wrote:
>
>> For what it's worth, the real algorithm would be as follows. I
>> hadn't had enough coffee yet, and I forgot the UPDATE bit.
>>
>> IF (a query matching your old data returns rows) THEN UPDATE with
>> your new data ELSE INSERT your new data
>
> Still exists race condition. Your race comes from testing existence,
> then creating/modifying data afterwards. You need to make the
> test/set atomic else you have race.

I guess when I wrote that the algorithm would have to be implemented in
an atomic manner, it fell on deaf ears.

That said, perhaps implementing a good MERGE would be not such a bad
idea for PostgreSQL 8.4.

Colin

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Robert Treat 2007-12-11 05:14:20 Re: partitioned table query question
Previous Message Tom Lane 2007-12-11 05:04:29 Re: partitioned table query question