Dean Rasheed <dean.a.rasheed@googlemail.com> writes:
> The constraint needs to be declared DEFERRABLE before you can defer
> it, but yes, I agree this is not a helpful error message.
> [The reason is that it actually searches for the trigger enforcing the
> constraint, and there isn't one if it's not deferrable. So the current
> code can't distinguish between a non-existent unique constraint and a
> non-deferrable one.]
Yeah. Is it worth searching pg_constraint first, just so that we can
give a better error message?
Actually, it strikes me that if we did it that way, we could search
pg_trigger using the constraint OID instead of name, which would permit
replacing the index on tgconstrname with a presumably much smaller one
on tgconstraint. And the bogus rechecks on namespace in
AfterTriggerSetState could probably be simplified too ...
regards, tom lane