MERGE ... WHEN NOT MATCHED BY SOURCE
Dean Rasheed <dean.a.rasheed@gmail.com>
From: Dean Rasheed <dean.a.rasheed@gmail.com>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2022-12-30T16:56:17Z
Lists: pgsql-hackers
Attachments
- support-merge-when-not-matched-by-source-v1.patch (text/x-patch) patch v1
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
Commits
-
Add support for MERGE ... WHEN NOT MATCHED BY SOURCE.
- 0294df2f1f84 17.0 landed
-
Reindex toast before its main relation in reindex_relation()
- f2bf8fb04886 17.0 cited