diff options
-rw-r--r-- | doc/src/sgml/ref/create_trigger.sgml | 13 | ||||
-rw-r--r-- | doc/src/sgml/trigger.sgml | 12 |
2 files changed, 22 insertions, 3 deletions
diff --git a/doc/src/sgml/ref/create_trigger.sgml b/doc/src/sgml/ref/create_trigger.sgml index 4bde8150122..42172ea1da2 100644 --- a/doc/src/sgml/ref/create_trigger.sgml +++ b/doc/src/sgml/ref/create_trigger.sgml @@ -410,6 +410,19 @@ UPDATE OF <replaceable>column_name1</replaceable> [, <replaceable>column_name2</ </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> In <productname>PostgreSQL</productname> versions before 7.3, it was necessary to declare trigger functions as returning the placeholder type <type>opaque</>, rather than <type>trigger</>. To support loading diff --git a/doc/src/sgml/trigger.sgml b/doc/src/sgml/trigger.sgml index 22966c06dc0..4d3fc8e0f89 100644 --- a/doc/src/sgml/trigger.sgml +++ b/doc/src/sgml/trigger.sgml @@ -56,15 +56,21 @@ <para> On views, triggers can be defined to execute instead of <command>INSERT</command>, <command>UPDATE</command>, or - <command>DELETE</command> operations. <literal>INSTEAD OF</> triggers + <command>DELETE</command> operations. + Such <literal>INSTEAD OF</literal> triggers are fired once for each row that needs to be modified in the view. It is the responsibility of the - trigger's function to perform the necessary modifications to the - underlying base tables and, where appropriate, return the modified + trigger's function to perform the necessary modifications to the view's + underlying base table(s) and, where appropriate, return the modified row as it will appear in the view. Triggers on views can also be defined to execute once per <acronym>SQL</acronym> statement, before or after <command>INSERT</command>, <command>UPDATE</command>, or <command>DELETE</command> operations. + However, such triggers are fired only if there is also + an <literal>INSTEAD OF</literal> trigger on the view. Otherwise, + any statement targeting the view must be rewritten into a statement + affecting its underlying base table(s), and then the triggers + that will be fired are the ones attached to the base table(s). </para> <para> |