Hi, On Tuesday 29 December 2015 19:40:44 Gavin Wahl wrote: > What does it even mean for constraints to be checked at savepoint commit? I > would expect this to not cause any errors: > > with atomic(): > # insert invalid fk > with atomic(check_deferred_constraints=True): > # do stuff that doesn't invalidate any contraints > # delete the invalid fk inserted before >
I think your expectation is wrong, for both technical and "ideological" reasons. Technically, you can easily do things in the inner block which, although they do not violate any constraints in themselves, rely on the invalid FK record. If that were allowed to pass silently, we would violate the expectation that "if the inner block succeeded, then things in it are ok". Philosophically, I don't think "checking the constraints only for things I changed here" is a valid *logical* operation, as you seem to imply; a database is valid or broken as a whole. The fact that we can get away with checking only the changes at a transaction limit is an *implementation* shortcut, valid only as far as it is logically equivalent to checking the whole database. Shai.
