Add documentation for the recent 'ALSO' patch for CREATE RULE. Along
authorNeil Conway
Tue, 9 Mar 2004 19:30:21 +0000 (19:30 +0000)
committerNeil Conway
Tue, 9 Mar 2004 19:30:21 +0000 (19:30 +0000)
the way, fix a typo and make a few SGML cleanups.

doc/src/sgml/ref/create_rule.sgml

index 412ebcd66b63b93dd480148e0ebf4e5a03d918ed..0ba20e3ce3b545136fd10750012953240dbd43e9 100644 (file)
@@ -1,5 +1,5 @@
 
 
@@ -22,7 +22,7 @@ PostgreSQL documentation
 
 CREATE [ OR REPLACE ] RULE name AS ON event
     TO table [ WHERE condition ]
-    DO [ INSTEAD ] { NOTHING | command | ( command ; command ... ) }
+    DO [ ALSO | INSTEAD ] { NOTHING | command | ( command ; command ... ) }
 
  
 
@@ -43,13 +43,13 @@ CREATE [ OR REPLACE ] RULE name AS
    or deletions in database tables.  Roughly speaking, a rule causes
    additional commands to be executed when a given command on a given
    table is executed.  Alternatively, an INSTEAD
-   rule can replace a given command by another, or cause a command 
-   not to be executed at all.  Rules are used to implement table 
-   views as well.  It is important to realize that a rule is really 
-   a command transformation mechanism, or command macro.  The 
-   transformation happens before the execution of the commands starts.  
-   If you actually want an operation that fires independently for each 
-   physical row, you probably want to use a trigger, not a rule.  
+   rule can replace a given command by another, or cause a command
+   not to be executed at all.  Rules are used to implement table
+   views as well.  It is important to realize that a rule is really
+   a command transformation mechanism, or command macro.  The
+   transformation happens before the execution of the commands starts.
+   If you actually want an operation that fires independently for each
+   physical row, you probably want to use a trigger, not a rule.
    More information about the rules system is in .
   
   
@@ -111,7 +111,7 @@ CREATE [ OR REPLACE ] RULE name AS
     event
     
      
-      The even is one of SELECT,
+      The event is one of SELECT,
       INSERTUPDATE, or
       DELETE.
      
@@ -132,10 +132,10 @@ CREATE [ OR REPLACE ] RULE name AS
     condition
     
      
-      Any SQL conditional expression (returning boolean).
-      The condition expression may not refer to any tables except
-      NEW and OLD, and may not
-      contain aggregate functions.
+      Any SQL conditional expression (returning
+      boolean).  The condition expression may not refer
+      to any tables except NEW and OLD, and
+      may not contain aggregate functions.
      
     
    
@@ -145,8 +145,24 @@ CREATE [ OR REPLACE ] RULE name AS
     
      
       INSTEAD indicates that the commands should be
-      executed instead of the original command, not in
-      addition to the original command.
+      executed instead of the original command.
+     
+    
+   
+
+   
+    
+    
+     
+      ALSO indicates that the commands should be
+      executed in addition to the original
+      command.
+     
+
+     
+      If neither ALSO nor
+      INSTEAD is specified, ALSO
+      is the default.
      
     
    
@@ -156,9 +172,9 @@ CREATE [ OR REPLACE ] RULE name AS
     
      
       The command or commands that make up the rule action.  Valid
-      commands are <literal>SELECT>,
-      <literal>INSERT, UPDATE>,
-      <literal>DELETE, or NOTIFY>.
+      commands are <command>SELECT>,
+      <command>INSERT, UPDATE>,
+      <command>DELETE, or NOTIFY>.
      
     
    
@@ -215,14 +231,14 @@ SELECT * FROM t1;
    issued even if there are not any rows that the rule should apply
    to.  For example, in
 
-CREATE RULE notify_me AS ON UPDATE TO mytable DO NOTIFY mytable;
+CREATE RULE notify_me AS ON UPDATE TO mytable DO ALSO NOTIFY mytable;
 
 UPDATE mytable SET name = 'foo' WHERE id = 42;
 
    one NOTIFY event will be sent during the
-   UPDATE, whether or not there are any rows with
-   id = 42.  This is an implementation restriction
-   that may be fixed in future releases.
+   UPDATE, whether or not there are any rows that
+   match the condition id = 42.  This is an
+   implementation restriction that may be fixed in future releases.
   
  
 
@@ -232,7 +248,7 @@ UPDATE mytable SET name = 'foo' WHERE id = 42;
   
    CREATE RULE is a
    PostgreSQL language extension, as is the
-   entire rules system.
+   entire query rewrite system.