From 7cbe57c34dec4860243e6d0f81738cfbb6e5d069 Mon Sep 17 00:00:00 2001 From: Noah Misch Date: Sun, 23 Mar 2014 02:16:34 -0400 Subject: Offer triggers on foreign tables. This covers all the SQL-standard trigger types supported for regular tables; it does not cover constraint triggers. The approach for acquiring the old row mirrors that for view INSTEAD OF triggers. For AFTER ROW triggers, we spool the foreign tuples to a tuplestore. This changes the FDW API contract; when deciding which columns to populate in the slot returned from data modification callbacks, writable FDWs will need to check for AFTER ROW triggers in addition to checking for a RETURNING clause. In support of the feature addition, refactor the TriggerFlags bits and the assembly of old tuples in ModifyTable. Ronan Dunklau, reviewed by KaiGai Kohei; some additional hacking by me. --- doc/src/sgml/ref/create_trigger.sgml | 43 ++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 17 deletions(-) (limited to 'doc/src/sgml/ref/create_trigger.sgml') diff --git a/doc/src/sgml/ref/create_trigger.sgml b/doc/src/sgml/ref/create_trigger.sgml index a8fba49e4c3..d270d66c574 100644 --- a/doc/src/sgml/ref/create_trigger.sgml +++ b/doc/src/sgml/ref/create_trigger.sgml @@ -43,9 +43,10 @@ CREATE [ CONSTRAINT ] TRIGGER name CREATE TRIGGER creates a new trigger. The - trigger will be associated with the specified table or view and will - execute the specified function function_name when certain events occur. + trigger will be associated with the specified table, view, or foreign table + and will execute the specified + function function_name when + certain events occur. @@ -93,7 +94,7 @@ CREATE [ CONSTRAINT ] TRIGGER name The following table summarizes which types of triggers may be used on - tables and views: + tables, views, and foreign tables: @@ -110,8 +111,8 @@ CREATE [ CONSTRAINT ] TRIGGER name BEFORE INSERT/UPDATE/DELETE - Tables - Tables and views + Tables and foreign tables + Tables, views, and foreign tables TRUNCATE @@ -121,8 +122,8 @@ CREATE [ CONSTRAINT ] TRIGGER name AFTER INSERT/UPDATE/DELETE - Tables - Tables and views + Tables and foreign tables + Tables, views, and foreign tables TRUNCATE @@ -164,13 +165,13 @@ CREATE [ CONSTRAINT ] TRIGGER name constraint trigger. This is the same as a regular trigger except that the timing of the trigger firing can be adjusted using . - Constraint triggers must be AFTER ROW triggers. They can - be fired either at the end of the statement causing the triggering event, - or at the end of the containing transaction; in the latter case they are - said to be deferred. A pending deferred-trigger firing can - also be forced to happen immediately by using SET CONSTRAINTS. - Constraint triggers are expected to raise an exception when the constraints - they implement are violated. + Constraint triggers must be AFTER ROW triggers on tables. They + can be fired either at the end of the statement causing the triggering + event, or at the end of the containing transaction; in the latter case they + are said to be deferred. A pending deferred-trigger firing + can also be forced to happen immediately by using SET + CONSTRAINTS. Constraint triggers are expected to raise an exception + when the constraints they implement are violated. @@ -244,8 +245,8 @@ UPDATE OF column_name1 [, column_name2table_name - The name (optionally schema-qualified) of the table or view the trigger - is for. + The name (optionally schema-qualified) of the table, view, or foreign + table the trigger is for. @@ -481,6 +482,14 @@ CREATE TRIGGER view_insert Compatibility + + The CREATE TRIGGER statement in PostgreSQL implements a subset of the -- cgit v1.2.3