Mladen Gogala <mladen.gogala@vmsinfo.com> writes:
> In Oracle, deferrable primary keys are enforced by non-unique indexes.
> That seems logical,
... maybe to an Oracle guy ...
> When the constraint is deferred in the transaction block, however, it
> tolerates duplicate values until the end of transaction:
Sure. That's exactly per spec: the check is deferred to end of
transaction. If the duplicated index entries are both/all still live
at that time, you get an error.
We do still execute the insertion-time uniqueness check, but instead of
throwing an error on failure, we just queue a trigger event to recheck
that key before commit. If the insertion-time check passes then there's
no need for a recheck later. This is a win because the insertion-time
check is cheap, being integrated into the insertion process itself.
regards, tom lane