Maksim Likharev wrote:
>
> Finding if the duplicate value exists and inserting if not.

Ok, thanks but I think it is still vulnerable to a race condition.

> I do not know how that will work for PG, but in Microsoft SQL Server
> you can do following
> BEGIN TRANSACTION
> UPDATE [val] = [val]
>       WHERE ....
> INSERT ...
> COMMIT TRANSACTION
>
> so basically by updating specific row ( let say you have such row )
> in transaction, row/page lock will be held until end of transaction
> and concurrent UPDATE will wait until you are done.
> Kind of semaphore.

Why the UPDATE? And in postgres every query runs in it's own transaction
so no need for the explicit BEGIN / END block.

So can't see how your solution is any better than the previous one :)

Thanks,

Jean-Christian Imbeault


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Reply via email to