mirror of
https://github.com/postgres/postgres.git
synced 2025-12-21 05:21:08 +03:00
Support MERGE into updatable views.
This allows the target relation of MERGE to be an auto-updatable or trigger-updatable view, and includes support for WITH CHECK OPTION, security barrier views, and security invoker views. A trigger-updatable view must have INSTEAD OF triggers for every type of action (INSERT, UPDATE, and DELETE) mentioned in the MERGE command. An auto-updatable view must not have any INSTEAD OF triggers. Mixing auto-update and trigger-update actions (i.e., having a partial set of INSTEAD OF triggers) is not supported. Rule-updatable views are also not supported, since there is no rewriter support for non-SELECT rules with MERGE operations. Dean Rasheed, reviewed by Jian He and Alvaro Herrera. Discussion: https://postgr.es/m/CAEZATCVcB1g0nmxuEc-A+gGB0HnfcGQNGYH7gS=7rq0u0zOBXA@mail.gmail.com
This commit is contained in:
@@ -132,9 +132,9 @@ DELETE
|
||||
<term><replaceable class="parameter">target_table_name</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The name (optionally schema-qualified) of the target table to merge into.
|
||||
If <literal>ONLY</literal> is specified before the table name, matching
|
||||
rows are updated or deleted in the named table only. If
|
||||
The name (optionally schema-qualified) of the target table or view to
|
||||
merge into. If <literal>ONLY</literal> is specified before a table
|
||||
name, matching rows are updated or deleted in the named table only. If
|
||||
<literal>ONLY</literal> is not specified, matching rows are also updated
|
||||
or deleted in any tables inheriting from the named table. Optionally,
|
||||
<literal>*</literal> can be specified after the table name to explicitly
|
||||
@@ -142,6 +142,16 @@ DELETE
|
||||
<literal>ONLY</literal> keyword and <literal>*</literal> option do not
|
||||
affect insert actions, which always insert into the named table only.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
If <replaceable class="parameter">target_table_name</replaceable> is a
|
||||
view, it must either be automatically updatable with no
|
||||
<literal>INSTEAD OF</literal> triggers, or it must have
|
||||
<literal>INSTEAD OF</literal> triggers for every type of action
|
||||
(<literal>INSERT</literal>, <literal>UPDATE</literal>, and
|
||||
<literal>DELETE</literal>) specified in the <literal>WHEN</literal>
|
||||
clauses. Views with rules are not supported.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@@ -486,7 +496,11 @@ MERGE <replaceable class="parameter">total_count</replaceable>
|
||||
the action's event type.
|
||||
</para>
|
||||
</listitem>
|
||||
</orderedlist></para>
|
||||
</orderedlist>
|
||||
If the target relation is a view with <literal>INSTEAD OF ROW</literal>
|
||||
triggers for the action's event type, they are used to perform the
|
||||
action instead.
|
||||
</para>
|
||||
</listitem>
|
||||
</orderedlist></para>
|
||||
</listitem>
|
||||
|
||||
Reference in New Issue
Block a user