Merge docs for CREATE CONSTRAINT TRIGGER and CREATE TRIGGER
authorAlvaro Herrera
Tue, 9 Nov 2010 19:52:46 +0000 (16:52 -0300)
committerAlvaro Herrera
Tue, 9 Nov 2010 19:52:46 +0000 (16:52 -0300)
doc/src/sgml/ref/allfiles.sgml
doc/src/sgml/ref/create_constraint.sgml [deleted file]
doc/src/sgml/ref/create_trigger.sgml
doc/src/sgml/reference.sgml

index f5d67a207876cd40f64f4736575409e06cfa4b4b..a352a431419b8b36722f41a85a716d4f3a21a449 100644 (file)
@@ -46,7 +46,6 @@ Complete list of usable sgml source files in this directory.
 
 
 
-
 
 
 
diff --git a/doc/src/sgml/ref/create_constraint.sgml b/doc/src/sgml/ref/create_constraint.sgml
deleted file mode 100644 (file)
index 3ec3f74..0000000
+++ /dev/null
@@ -1,171 +0,0 @@
-
-
-
-  CREATE CONSTRAINT TRIGGER
-  7
-  SQL - Language Statements
-
-  CREATE CONSTRAINT TRIGGER
-  define a new constraint trigger
-
-  CREATE CONSTRAINT TRIGGER
-
-
-CREATE CONSTRAINT TRIGGER name
-    AFTER event [ OR ... ]
-    ON table_name
-    [ FROM referenced_table_name ]
-    { NOT DEFERRABLE | [ DEFERRABLE ] { INITIALLY IMMEDIATE | INITIALLY DEFERRED } }
-    FOR EACH ROW
-    [ WHEN ( condition ) ]
-    EXECUTE PROCEDURE function_name ( arguments )
-
-
-  Description
-
-  
-   CREATE CONSTRAINT TRIGGER creates a
-   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.
-  
-
-  Parameters
-
-  
-   
-    name
-    
-     
-      The name of the constraint trigger.  This is also the name to use
-      when modifying the trigger's behavior using SET CONSTRAINTS.
-      The name cannot be schema-qualified — the trigger inherits the
-      schema of its table.
-     
-    
-   
-
-   
-    event
-    
-     
-      One of INSERTUPDATE, or
-      DELETE; this specifies the event that will fire the
-      trigger. Multiple events can be specified using OR.
-     
-    
-   
-
-   
-    table_name
-    
-     
-      The (possibly schema-qualified) name of the table in which
-      the triggering events occur.
-     
-    
-   
-
-   
-    referenced_table_name
-    
-     
-      The (possibly schema-qualified) name of another table referenced by the
-      constraint.  This option is used for foreign-key constraints and is not
-      recommended for general use.
-     
-    
-   
-
-   
-    DEFERRABLE
-    NOT DEFERRABLE
-    INITIALLY IMMEDIATE
-    INITIALLY DEFERRED
-    
-     
-      The default timing of the trigger.
-      See the 
-      documentation for details of these constraint options.
-     
-    
-   
-
-   
-    condition
-    
-     
-      A Boolean expression that determines whether the trigger function
-      will actually be executed.  This acts the same as in 
-      linkend="SQL-CREATETRIGGER">.
-      Note in particular that evaluation of the WHEN
-      condition is not deferred, but occurs immediately after the row
-      update operation is performed.  If the condition does not evaluate
-      to true then the trigger is not queued for deferred
-      execution.
-     
-    
-   
-
-   
-    function_name
-    
-     
-      The function to call when the trigger is fired. See 
-      linkend="SQL-CREATETRIGGER"> for
-      details.
-     
-    
-   
-
-   
-    arguments
-    
-     
-      Optional argument strings to pass to the trigger function. See 
-      linkend="SQL-CREATETRIGGER"> for
-      details.
-     
-    
-   
-  
-  
-
-  Compatibility
-  
-   CREATE CONSTRAINT TRIGGER is a
-   PostgreSQL extension of the SQL
-   standard.
-  
-
-  See Also
-
-  
-   
-   
-   
-  
-
index 95d67aad6f5c0db72103967ac218b9e316bdfdca..492611eea8b2c41916cbddf2296435373147a864 100644 (file)
@@ -21,8 +21,10 @@ PostgreSQL documentation
 
  
 
-CREATE TRIGGER name { BEFORE | AFTER | INSTEAD OF } { event [ OR ... ] }
+CREATE [ CONSTRAINT ] TRIGGER name { BEFORE | AFTER | INSTEAD OF } { event [ OR ... ] }
     ON table [ FOR [ EACH ] { ROW | STATEMENT } ]
+    [ FROM referenced_table_name ]
+    { NOT DEFERRABLE | [ DEFERRABLE ] { INITIALLY IMMEDIATE | INITIALLY DEFERRED } }
     [ WHEN ( condition ) ]
     EXECUTE PROCEDURE function_name ( arguments )
 
@@ -149,6 +151,20 @@ CREATE TRIGGER name { BEFORE | AFTE
    they will be fired in alphabetical order by name.
   
 
+  
+   When the CONSTRAINT option is specified, this command creates a
+   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.
+  
+
   
    SELECT does not modify any rows so you cannot
    create SELECT triggers. Rules and views are more
@@ -170,6 +186,10 @@ CREATE TRIGGER name { BEFORE | AFTE
      
       The name to give the new trigger.  This must be distinct from
       the name of any other trigger for the same table.
+      The name cannot be schema-qualified — the trigger inherits the
+      schema of its table.  For a constraint trigger, this is also the name to
+      use when modifying the trigger's behavior using
+      SET CONSTRAINTS.
      
     
    
@@ -181,7 +201,8 @@ CREATE TRIGGER name { BEFORE | AFTE
     
      
       Determines whether the function is called before, after, or instead of
-      the event.
+      the event.  A constraint trigger can only be specified as
+      AFTER.
      
     
    
@@ -222,6 +243,33 @@ UPDATE OF column_name1 [, column_name2
     
    
 
+   
+    referenced_table_name
+    
+     
+      The (possibly schema-qualified) name of another table referenced by the
+      constraint.  This option is used for foreign-key constraints and is not
+      recommended for general use.  This can only be specified for
+      constraint triggers.
+     
+    
+   
+
+   
+    DEFERRABLE
+    NOT DEFERRABLE
+    INITIALLY IMMEDIATE
+    INITIALLY DEFERRED
+    
+     
+      The default timing of the trigger.
+      See the  documentation for details of
+      these constraint options.  This can only be specified for constraint
+      triggers.
+     
+    
+   
+
    
     FOR EACH ROW
     FOR EACH STATEMENT
@@ -231,7 +279,8 @@ UPDATE OF column_name1 [, column_name2
       This specifies whether the trigger procedure should be fired
       once for every row affected by the trigger event, or just once
       per SQL statement. If neither is specified, FOR EACH
-      STATEMENT is the default.
+      STATEMENT is the default.  Constraint triggers can only
+      be specified FOR EACH ROW.
      
     
    
@@ -263,6 +312,13 @@ UPDATE OF column_name1 [, column_name2
       Currently, WHEN expressions cannot contain
       subqueries.
      
+
+     
+      Note that for constraint triggers, evaluation of the WHEN
+      condition is not deferred, but occurs immediately after the row update
+      operation is performed. If the condition does not evaluate to true then
+      the trigger is not queued for deferred execution.
+     
     
    
 
@@ -481,6 +537,12 @@ CREATE TRIGGER view_insert
    ability to define statement-level triggers on views.
   
 
+  
+   CREATE CONSTRAINT TRIGGER is a
+   PostgreSQL extension of the SQL
+   standard.
+  
+
  
 
  
@@ -490,6 +552,7 @@ CREATE TRIGGER view_insert
    
    
    
+   
   
  
 
index 463746cda3a0553cb43c3ef76623aaa055fd7327..13de002792538595d0a7c23a9b79f19144dc328f 100644 (file)
@@ -74,7 +74,6 @@
    ©Table;
    &createAggregate;
    &createCast;
-   &createConstraint;
    &createConversion;
    &createDatabase;
    &createDomain;