public inbox for [email protected]
help / color / mirror / Atom feedFrom: Mark Kirkwood <[email protected]>
To: Mark Kirkwood <[email protected]>
Cc: Jim C. Nasby <[email protected]>
Cc: [email protected]
Cc: [email protected]
Subject: Re: Summary table trigger example race condition
Date: Sun, 08 Jan 2006 16:13:01 +1300
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
Mark Kirkwood wrote:
> Jim C. Nasby wrote:
>
>> On Fri, Jan 06, 2006 at 02:00:34PM +1300, Mark Kirkwood wrote:
>>
>>> However, I think the actual change is not quite right - after running
>>
>>
>>
>> DOH! It would be good if doc/src had a better mechanism for handling
>> code; one that would allow for writing the code natively (so you don't
>> have to worry about translating < into < and > into >) and for
>> unit testing the different pieces of code.
>>
>
> Yes it would - I usually build the SGML -> HTML, then cut the code out
> of a browser session to test - the pain is waiting for the docs to build.
>
>> Anyway, updated patch attached.
>>
>
> This one is good!
>
After re-examining the original code, it looks like it was not actually
vulnerable to a race condition! (it does the UPDATE, then if not found
will do an INSERT, and handle unique violation with a repeat of the same
UPDATE - i.e three DML statements, which are enough to handle the race
in this case).
However Jim's change handles the race needing only two DML statements in
a loop, which seems much more elegant! In addition it provides a nice
example of the 'merge' style code shown in e.g 36-1.
Cheers
Mark
view thread (14+ messages) latest in thread
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 using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Summary table trigger example race condition
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox