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 &lt; and > into &gt;) 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.



---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Reply via email to