Re: WIP: generalized index constraints
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jeff Davis <pgsql@j-davis.com>
Cc: pgsql-hackers@postgresql.org
Date: 2009-09-20T16:31:50Z
Lists: pgsql-hackers
Jeff Davis <pgsql@j-davis.com> writes: > On Sat, 2009-09-19 at 18:00 -0400, Tom Lane wrote: >> Well, you can't do it *exactly* the same way btree does, but what >> I would envision is first insert the index tuple and then do a >> dirty-snapshot search for conflicting tuples. The interlock against >> conflicting concurrent inserts doesn't need all this new infrastructure >> you propose; just wait to see if conflicting transactions commit, same >> as we do now. And I do maintain that that sort of code has a high risk >> of undetected bugs. > How do you prevent deadlocks in the following case? > T1: inserts into index > T2: inserts into index > T1: checks index for conflicts, finds T2 > T2: checks index for conflicts, finds T1 You get a deadlock failure, because both transactions will wait for each other. So what? It's an error in any case, and you can get a reported deadlock in constraint-enforcement scenarios today (conflicting FK changes, for instance). regards, tom lane