Re: Select for insert possible?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Lincoln Yeoh <lyeoh(at)pop(dot)jaring(dot)my>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Select for insert possible?
Date: 2001-03-24 17:59:51
Message-ID: 23206.985456791@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Lincoln Yeoh <lyeoh(at)pop(dot)jaring(dot)my> writes:
> Is it technically possible for there to be a "select for insert"? e.g.
> other select for inserts with the same effective where clause will block
> even if no rows are there yet.

What would you define as the "same effective where clause"? Shades of
the halting problem, I think :-(.

I'd recommend grabbing a table-level EXCLUSIVE MODE lock, which will
allow reads to proceed but lock out other updaters.

Alternatively, consider whether you can't rely on a unique index to
prevent multiple processes from inserting the "same" not-there-yet row.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2001-03-24 18:31:07 Re: Call for platforms
Previous Message Lincoln Yeoh 2001-03-24 17:52:16 Select for insert possible?