mirror of
https://github.com/postgres/postgres.git
synced 2025-12-21 05:21:08 +03:00
Doc: note that statement-level view triggers require an INSTEAD OF trigger.
If a view lacks an INSTEAD OF trigger, DML on it can only work by rewriting the command into a command on the underlying base table(s). Then we will fire triggers attached to those table(s), not those for the view. This seems appropriate from a consistency standpoint, but nowhere was the behavior explicitly documented, so let's do that. There was some discussion of throwing an error or warning if a statement trigger is created on a view without creating a row INSTEAD OF trigger. But a simple implementation of that would result in dump/restore ordering hazards. Given that it's been like this all along, and we hadn't heard a complaint till now, a documentation improvement seems sufficient. Per bug #15106 from Pu Qun. Back-patch to all supported branches. Discussion: https://postgr.es/m/152083391168.1215.16892140713507052796@wrigleys.postgresql.org
This commit is contained in:
@@ -499,6 +499,19 @@ UPDATE OF <replaceable>column_name1</replaceable> [, <replaceable>column_name2</
|
||||
each affected row in a transition relation once and only once.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Statement-level triggers on a view are fired only if the action on the
|
||||
view is handled by a row-level <literal>INSTEAD OF</literal> trigger.
|
||||
If the action is handled by an <literal>INSTEAD</literal> rule, then
|
||||
whatever statements are emitted by the rule are executed in place of the
|
||||
original statement naming the view, so that the triggers that will be
|
||||
fired are those on tables named in the replacement statements.
|
||||
Similarly, if the view is automatically updatable, then the action is
|
||||
handled by automatically rewriting the statement into an action on the
|
||||
view's base table, so that the base table's statement-level triggers are
|
||||
the ones that are fired.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Modifying a partitioned table or a table with inheritance children fires
|
||||
statement-level triggers attached to the explicitly named table, but not
|
||||
|
||||
Reference in New Issue
Block a user