Re: Solution to UPDATE or INSERT Problem

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Curt Sampson <cjs(at)cynic(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Solution to UPDATE or INSERT Problem
Date: 2004-01-19 05:37:31
Message-ID: 20924.1074490651@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Curt Sampson <cjs(at)cynic(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Pavel Stehule 2004-01-19 05:58:55 Re: Tool to ease development of plpgsql
Previous Message Tom Lane 2004-01-19 05:34:16 Re: Solution to UPDATE or INSERT Problem