Peter Eisentraut <peter_e@gmx.net> writes:
> Tom Lane wrote:
>> Surely they require a unique constraint --- else the behavior isn't
>> even well defined, is it?
> They require that the merge condition does not match for more than one
> row, but since the merge condition can do just about anything, there is
> no guarantee that a unique constraint encompasses it.
ISTM to be a reasonable implementation restriction that there be a
constraint by which the system can prove that there is at most one
matching row. Per other comments in this thread, we'd not be the only
implementation making such a restriction.
(Certainly, if I were a DBA and were told that the performance of MERGE
would go to hell in a handbasket if I had no such constraint, I'd make
sure there was one. I don't think there is very much of a use-case for
the general scenario.)
regards, tom lane