On ons, 2010-08-11 at 13:23 +0300, Marko Tiikkaja wrote:
> But you'd have to somehow make the constraints to be checked
> with true serializability, and that part of the original suggestion
> seemed to be completely missing. Not sure how hard that would be
> though.
I don't think somehow running the constraint checks at a different
transaction isolation level than the rest of the transaction is
sensible. I imagine the solution would look similar to how foreign keys
do it: take a lock on the rows that are required for constraint
satisfaction. For general assertions, this would require predicate
locking. But also notice that for the (SELECT count(*) FROM tbl) = N
case, this is the same as a table lock. I don't think there is any
magic around it.