Race hazard deleting using CTID? - Mailing list pgsql-general

From Peter Headland
Subject Race hazard deleting using CTID?
Date
Msg-id 71F491F5DA99604A80DE49424BF3D02B0C7293A0@exchange8.actuate.com
Whole thread Raw
Responses Re: Race hazard deleting using CTID?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
I believe that the following statement was originally suggested by Tom Lane; I got it from Pavel Stehule's PostgreSQL
Tipspage.
 
My question is, does this code contain a race hazard, because the list from the SELECT might get changed by another
sessionbefore the DELETE uses it?
 

  delete from del where ctid = any(array(select ctid from del limit 10))

If so, am I correct to think that adding FOR UPDATE to create the version below would eliminate the hazard?

  delete from del where ctid = any(array(select ctid from del limit 10 for update))

-- 
Peter Headland
Architect
Actuate Corporation


pgsql-general by date:

Previous
From: "Peter Headland"
Date:
Subject: Does PERFORM hold a lock?
Next
From: Tom Lane
Date:
Subject: Re: Race hazard deleting using CTID?