Re: Solution to UPDATE or INSERT Problem - Mailing list pgsql-general

From Tom Lane
Subject Re: Solution to UPDATE or INSERT Problem
Date
Msg-id 20924.1074490651@sss.pgh.pa.us
Whole thread Raw
In response to Solution to UPDATE or INSERT Problem  (Curt Sampson <cjs@cynic.net>)
List pgsql-general
Curt Sampson <cjs@cynic.net> writes:
> But why does session 2 hang
> in this instance?

Because the sub-SELECT sees a snapshot of transactions that were already
committed at the start of session 2's transaction.  If session 1 hasn't
committed yet, the EXISTS will return false.  The actual INSERT will
notice the inserted-but-not-yet-committed row, and will block waiting to
see whether it gets committed or not.

            regards, tom lane

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Solution to UPDATE or INSERT Problem
Next
From: Pavel Stehule
Date:
Subject: Re: Tool to ease development of plpgsql