MERGE ... WHEN NOT MATCHED BY SOURCE - Mailing list pgsql-hackers

From Dean Rasheed
Subject MERGE ... WHEN NOT MATCHED BY SOURCE
Date
Msg-id CAEZATCWqnKGc57Y_JanUBHQXNKcXd7r=0R4NEZUVwP+syRkWbA@mail.gmail.com
Whole thread Raw
Responses Re: MERGE ... WHEN NOT MATCHED BY SOURCE  (Dean Rasheed <dean.a.rasheed@gmail.com>)
List pgsql-hackers
This allows MERGE to UPDATE or DELETE target rows where there is no
matching source row. In addition, it allows the existing "WHEN NOT
MATCHED" syntax to include an optional "BY TARGET" to make its meaning
more explicit. E.g.,

MERGE INTO tgt USING src ON ...
  WHEN NOT MATCHED BY SOURCE THEN UPDATE/DELETE ...
  WHEN NOT MATCHED BY TARGET THEN INSERT ...

AFAIK, this is not part of the standard (though I only have a very old
draft copy). It is supported by at least 2 other major DB vendors
though, and I think it usefully rounds off the set of possible MERGE
actions.

Attached is a WIP patch. I haven't updated the docs yet, and there are
probably a few other things to tidy up and test, but the basic
functionality is there.

Regards,
Dean

Attachment

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: split TOAST support out of postgres.h
Next
From: Joseph Koshakow
Date:
Subject: Re: Infinite Interval