"Gregory Stark" <stark@enterprisedb.com> writes:
> On the other hand what happens if you have constraints not deferred, insert a
> record, then set constraints deferred and update it?
After having a coffee this is obviously not a problem since if you have
constraints not deferred then the constraint was checked immediately. We don't
have to do the constraint in that case even if the row was inserted by us but
that's an optimization that probably nobody cares about.
If you go the other direction from deferred to not deferred then the
constraint will be checked when you set the constraint to immediate so it's
safe to skip the constraint check if the keys match subsequently regardless of
whether we inserted the record.
--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com