Re: Summary table trigger example race condition

Поиск
Список
Период
Сортировка
От Mark Kirkwood
Тема Re: Summary table trigger example race condition
Дата
Msg-id 43C0833D.4040607@paradise.net.nz
обсуждение исходный текст
Ответ на Re: Summary table trigger example race condition  (Mark Kirkwood <markir@paradise.net.nz>)
Ответы Re: Summary table trigger example race condition
Список pgsql-patches
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


В списке pgsql-patches по дате отправления:

Предыдущее
От: Marko Kreen
Дата:
Сообщение: Re: [HACKERS] Inconsistent syntax in GRANT
Следующее
От: Neil Conway
Дата:
Сообщение: Re: psql tab completion enhancements