"Tom Lane" <tgl@sss.pgh.pa.us> writes
> Actually, on further thought, there's a really simple solution that
> we've used elsewhere: make sure you have the resource you need *before*
> you get into the critical section of code. I've applied the attached
> revised patch.
>
Oh, that's the one - why didn't think of it at the first time? :-)
Regards,
Qingqing