From 5defdef8aa0535b8e9365ea9cceee60d5731395f Mon Sep 17 00:00:00 2001 From: Dean Rasheed Date: Fri, 9 Dec 2022 10:00:01 +0000 Subject: Update MERGE docs to mention that ONLY is supported. Commit 7103ebb7aa added support for MERGE, which included support for inheritance hierarchies, but didn't document the fact that ONLY could be specified before the source and/or target tables to exclude tables inheriting from the tables specified. Update merge.sgml to mention this, and while at it, add some regression tests to cover it. Dean Rasheed, reviewed by Nathan Bossart. Backpatch to 15, where MERGE was added. Discussion: https://postgr.es/m/CAEZATCU0XM-bJCvpJuVRU3UYNRqEBS6g4-zH%3Dj9Ye0caX8F6uQ%40mail.gmail.com --- doc/src/sgml/ref/merge.sgml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/ref/merge.sgml b/doc/src/sgml/ref/merge.sgml index e07addaea42..0995fe0c046 100644 --- a/doc/src/sgml/ref/merge.sgml +++ b/doc/src/sgml/ref/merge.sgml @@ -22,13 +22,13 @@ PostgreSQL documentation [ WITH with_query [, ...] ] -MERGE INTO target_table_name [ [ AS ] target_alias ] +MERGE INTO [ ONLY ] target_table_name [ * ] [ [ AS ] target_alias ] USING data_source ON join_condition when_clause [...] where data_source is: -{ source_table_name | ( source_query ) } [ [ AS ] source_alias ] +{ [ ONLY ] source_table_name [ * ] | ( source_query ) } [ [ AS ] source_alias ] and when_clause is: @@ -129,6 +129,14 @@ DELETE The name (optionally schema-qualified) of the target table to merge into. + If ONLY is specified before the table name, matching + rows are updated or deleted in the named table only. If + ONLY is not specified, matching rows are also updated + or deleted in any tables inheriting from the named table. Optionally, + * can be specified after the table name to explicitly + indicate that descendant tables are included. The + ONLY keyword and * option do not + affect insert actions, which always insert into the named table only. @@ -151,7 +159,12 @@ DELETE The name (optionally schema-qualified) of the source table, view, or - transition table. + transition table. If ONLY is specified before the + table name, matching rows are included from the named table only. If + ONLY is not specified, matching rows are also included + from any tables inheriting from the named table. Optionally, + * can be specified after the table name to explicitly + indicate that descendant tables are included. -- cgit v1.2.3