Add ALSO keyword to CREATE RULE.
authorBruce Momjian
Tue, 9 Mar 2004 05:05:41 +0000 (05:05 +0000)
committerBruce Momjian
Tue, 9 Mar 2004 05:05:41 +0000 (05:05 +0000)
Fabien COELHO

doc/src/sgml/keywords.sgml
doc/src/sgml/rules.sgml
src/backend/parser/gram.y
src/backend/parser/keywords.c
src/test/regress/expected/rules.out
src/test/regress/sql/rules.sql

index 51e08a360e20d3eb289e66eb06f207ce5cd6d43e..e8f5d9b75c58121db3a7183ad885f6fa0f8a8655 100644 (file)
@@ -1,4 +1,4 @@
-
+
 
 
  <acronym>SQL</acronym> Key Words
     reserved
     reserved
    
+   
+    ALSO
+    non-reserved
+    
+    
+   
    
     ALTER
     non-reserved
index c719a651de13c6a991a0fd95bf2e214fd267d58f..a764dcfc5f441553ec42584e4f72aea48c61b73f 100644 (file)
@@ -1,4 +1,4 @@
-
+
 
 
 The Rule System
@@ -873,7 +873,7 @@ SELECT t1.a, t2.b, t1.ctid FROM t1, t2 WHERE t1.a = t2.a;
 
         
    
-       They can be INSTEAD or not.
+       They can be INSTEAD or ALSO (default).
    
    
 
@@ -904,7 +904,7 @@ SELECT t1.a, t2.b, t1.ctid FROM t1, t2 WHERE t1.a = t2.a;
 
 CREATE RULE rule_name AS ON event
     TO object [WHERE rule_qualification]
-    DO [INSTEAD] [action | (actions) | NOTHING];
+    DO [ALSO|INSTEAD] [action | (actions) | NOTHING];
 
 
     in mind.
@@ -920,7 +920,7 @@ CREATE RULE rule_name AS ON event
     Initially the query-tree list is empty.
     There can be zero (NOTHING key word), one, or multiple actions.
     To simplify, we will look at a rule with one action. This rule
-    can have a qualification or not and it can be INSTEAD or not.
+    can have a qualification or not and it can be INSTEAD or ALSO (default).
 
 
 
@@ -937,7 +937,7 @@ CREATE RULE rule_name AS ON event
 
     
      
-      No qualification and not INSTEAD
+      No qualification and ALSO
       
        
         the query tree from the rule action with the original query
@@ -957,7 +957,7 @@ CREATE RULE rule_name AS ON event
      
 
      
-      Qualification given and not INSTEAD
+      Qualification given and ALSO
       
        
         the query tree from the rule action with the rule
@@ -980,7 +980,7 @@ CREATE RULE rule_name AS ON event
      
     
 
-    Finally, if the rule is not INSTEAD, the unchanged original query tree is
+    Finally, if the rule is ALSO, the unchanged original query tree is
     added to the list. Since only qualified INSTEAD rules already add the
     original query tree, we end up with either one or two output query trees
     for a rule with one action.
@@ -1111,7 +1111,7 @@ INSERT INTO shoelace_log VALUES (
 
 
 
-    The rule is a qualified non-INSTEAD rule, so the rule system
+    The rule is a qualified ALSO rule, so the rule system
     has to return two query trees: the modified rule action and the original
     query tree. In step 1, the range table of the original query is
     incorporated into the rule's action query tree. This results in:
@@ -1190,7 +1190,7 @@ INSERT INTO shoelace_log VALUES (
    
 
    
-    That's it.  Since the rule is not INSTEAD, we also output the
+    That's it.  Since the rule is ALSO, we also output the
     original query tree.  In short, the output from the rule system
     is a list of two query trees that correspond to these statements:
 
index 6057071653737b7604c853cef4b6c6b8168d9f1e..20db7fc6213d280e046509af4fdc8b1a6a64527d 100644 (file)
@@ -11,7 +11,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.446 2004/01/11 04:58:17 neilc Exp $
+ *   $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.447 2004/03/09 05:05:41 momjian Exp $
  *
  * HISTORY
  *   AUTHOR            DATE            MAJOR EVENT
@@ -332,7 +332,7 @@ static void doNegateFloat(Value *v);
 
 /* ordinary key words in alphabetical order */
 %token  ABORT_P ABSOLUTE_P ACCESS ACTION ADD AFTER
-   AGGREGATE ALL ALTER ANALYSE ANALYZE AND ANY ARRAY AS ASC
+   AGGREGATE ALL ALSO ALTER ANALYSE ANALYZE AND ANY ARRAY AS ASC
    ASSERTION ASSIGNMENT AT AUTHORIZATION
 
    BACKWARD BEFORE BEGIN_P BETWEEN BIGINT BINARY BIT
@@ -3610,6 +3610,7 @@ event:        SELECT                                  { $$ = CMD_SELECT; }
 
 opt_instead:
            INSTEAD                                 { $$ = TRUE; }
+           | ALSO                                  { $$ = FALSE; }
            | /*EMPTY*/                             { $$ = FALSE; }
        ;
 
index a94786690ed52e04190cdc4e43bab3a54aea0433..24430a9cc603f386be3c55c6bf02182b06c65cfd 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/parser/keywords.c,v 1.145 2004/02/21 00:34:52 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/parser/keywords.c,v 1.146 2004/03/09 05:05:41 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -38,6 +38,7 @@ static const ScanKeyword ScanKeywords[] = {
    {"after", AFTER},
    {"aggregate", AGGREGATE},
    {"all", ALL},
+   {"also", ALSO},
    {"alter", ALTER},
    {"analyse", ANALYSE},       /* British spelling */
    {"analyze", ANALYZE},
index f7f5db4244e43d5d75e18411560fd806d704de8e..902ff4472f6d8e4d9041cac3f9c391a44978f1b4 100644 (file)
@@ -34,19 +34,19 @@ create table rtest_system (sysname text, sysdesc text);
 create table rtest_interface (sysname text, ifname text);
 create table rtest_person (pname text, pdesc text);
 create table rtest_admin (pname text, sysname text);
-create rule rtest_sys_upd as on update to rtest_system do (
+create rule rtest_sys_upd as on update to rtest_system do also (
    update rtest_interface set sysname = new.sysname 
        where sysname = old.sysname;
    update rtest_admin set sysname = new.sysname 
        where sysname = old.sysname
    );
-create rule rtest_sys_del as on delete to rtest_system do (
+create rule rtest_sys_del as on delete to rtest_system do also (
    delete from rtest_interface where sysname = old.sysname;
    delete from rtest_admin where sysname = old.sysname;
    );
-create rule rtest_pers_upd as on update to rtest_person do 
+create rule rtest_pers_upd as on update to rtest_person do also
    update rtest_admin set pname = new.pname where pname = old.pname;
-create rule rtest_pers_del as on delete to rtest_person do 
+create rule rtest_pers_del as on delete to rtest_person do also
    delete from rtest_admin where pname = old.pname;
 --
 -- Tables and rules for the logging test
index 55c3805bd5f601ce07fcc2150f2678f15cc0d021..908c9804628944c1a1010f0d691c41734edc37cf 100644 (file)
@@ -36,22 +36,22 @@ create table rtest_interface (sysname text, ifname text);
 create table rtest_person (pname text, pdesc text);
 create table rtest_admin (pname text, sysname text);
 
-create rule rtest_sys_upd as on update to rtest_system do (
+create rule rtest_sys_upd as on update to rtest_system do also (
    update rtest_interface set sysname = new.sysname 
        where sysname = old.sysname;
    update rtest_admin set sysname = new.sysname 
        where sysname = old.sysname
    );
 
-create rule rtest_sys_del as on delete to rtest_system do (
+create rule rtest_sys_del as on delete to rtest_system do also (
    delete from rtest_interface where sysname = old.sysname;
    delete from rtest_admin where sysname = old.sysname;
    );
 
-create rule rtest_pers_upd as on update to rtest_person do 
+create rule rtest_pers_upd as on update to rtest_person do also
    update rtest_admin set pname = new.pname where pname = old.pname;
 
-create rule rtest_pers_del as on delete to rtest_person do 
+create rule rtest_pers_del as on delete to rtest_person do also
    delete from rtest_admin where pname = old.pname;
 
 --