]> granicus.if.org Git - postgresql/commitdiff
Reenabled parentheses for grouping multiple rule actions and
authorJan Wieck <JanWieck@Yahoo.com>
Sun, 7 Feb 1999 19:02:20 +0000 (19:02 +0000)
committerJan Wieck <JanWieck@Yahoo.com>
Sun, 7 Feb 1999 19:02:20 +0000 (19:02 +0000)
added this syntax to rules regression test so it will show up
if someone breaks it again.

Jan

src/backend/parser/gram.y
src/test/regress/expected/rules.out
src/test/regress/sql/rules.sql

index b29f76420faf28e38baa7324ca7d1de491ee5f35..e88b9073084cc8dc06468c7fc2553490da650f4e 100644 (file)
@@ -10,7 +10,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.52 1999/02/06 20:27:34 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.53 1999/02/07 19:02:19 wieck Exp $
  *
  * HISTORY
  *       AUTHOR                        DATE                    MAJOR EVENT
@@ -132,7 +132,7 @@ Oid param_type(int t); /* used in parse_expr.c */
                CreatedbStmt, DestroydbStmt, VacuumStmt, CursorStmt, SubSelect,
                UpdateStmt, InsertStmt, select_w_o_sort, SelectStmt, NotifyStmt, DeleteStmt, 
                ClusterStmt, ExplainStmt, VariableSetStmt, VariableShowStmt, VariableResetStmt,
-               CreateUserStmt, AlterUserStmt, DropUserStmt
+               CreateUserStmt, AlterUserStmt, DropUserStmt, RuleActionStmt
 
 %type <str>    opt_database1, opt_database2, location, encoding
 
@@ -163,7 +163,7 @@ Oid param_type(int t); /* used in parse_expr.c */
                result, relation_name_list, OptTableElementList,
                OptInherit, definition,
                opt_with, func_args, func_args_list,
-               oper_argtypes, OptStmtList, OptStmtBlock, OptStmtMulti,
+               oper_argtypes, RuleActionList, RuleActionBlock, RuleActionMulti,
                opt_column_list, columnList, opt_va_list, va_list,
                sort_clause, sortby_list, index_params, index_list, name_list,
                from_clause, from_list, opt_array_bounds, nest_array_bounds,
@@ -2058,7 +2058,7 @@ opt_column:  COLUMN                                               { $$ = COLUMN; }
 RuleStmt:  CREATE RULE name AS
                   { QueryIsRule=TRUE; }
                   ON event TO event_object where_clause
-                  DO opt_instead OptStmtList
+                  DO opt_instead RuleActionList
                                {
                                        RuleStmt *n = makeNode(RuleStmt);
                                        n->rulename = $3;
@@ -2071,34 +2071,31 @@ RuleStmt:  CREATE RULE name AS
                                }
                ;
 
-OptStmtList:  NOTHING                                  { $$ = NIL; }
-               | OptimizableStmt                               { $$ = lcons($1, NIL); }
-               | '[' OptStmtBlock ']'                  { $$ = $2; }
-/***S*I*D***/
-/* We comment this out because it produces a shift / reduce conflict 
- * with the select_w_o_sort rule */
-/*             | '(' OptStmtBlock ')'                  { $$ = $2; } */
+RuleActionList:  NOTHING                               { $$ = NIL; }
+               | SelectStmt                                    { $$ = lcons($1, NIL); }
+               | RuleActionStmt                                { $$ = lcons($1, NIL); }
+               | '[' RuleActionBlock ']'               { $$ = $2; }
+               | '(' RuleActionBlock ')'               { $$ = $2; } 
                ;
 
-OptStmtBlock:  OptStmtMulti
-                               {  $$ = $1; }
-               | OptimizableStmt
-                               { $$ = lcons($1, NIL); }
+RuleActionBlock:  RuleActionMulti              {  $$ = $1; }
+               | RuleActionStmt                                { $$ = lcons($1, NIL); }
                ;
 
-OptStmtMulti:  OptStmtMulti OptimizableStmt ';'
+RuleActionMulti:  RuleActionMulti RuleActionStmt
                                {  $$ = lappend($1, $2); }
-/***S*I***/
-/* We comment the next rule because it seems to be redundant
- * and produces 16 shift/reduce conflicts with the new SelectStmt rule
- * needed for EXCEPT and INTERSECT. So far I did not notice any
- * violations by removing the rule! */
-/*             | OptStmtMulti OptimizableStmt
-                               {  $$ = lappend($1, $2); } */
-               | OptimizableStmt ';'
+               | RuleActionMulti RuleActionStmt ';'
+                               {  $$ = lappend($1, $2); }
+               | RuleActionStmt ';'
                                { $$ = lcons($1, NIL); }
                ;
 
+RuleActionStmt:        InsertStmt
+               | UpdateStmt
+               | DeleteStmt
+               | NotifyStmt
+               ;
+
 event_object:  relation_name '.' attr_name
                                {
                                        $$ = makeNode(Attr);
index c45ae0965109c05faf139bd8a16a084d3e4dd63d..448551e54ded7ff127311cc0adb473ef7cbc4395 100644 (file)
@@ -13,16 +13,16 @@ QUERY: create table rtest_system (sysname text, sysdesc text);
 QUERY: create table rtest_interface (sysname text, ifname text);
 QUERY: create table rtest_person (pname text, pdesc text);
 QUERY: create table rtest_admin (pname text, sysname text);
-QUERY: create rule rtest_sys_upd1 as on update to rtest_system do
+QUERY: create rule rtest_sys_upd as on update to rtest_system do (
        update rtest_interface set sysname = new.sysname
                where sysname = current.sysname;
-QUERY: create rule rtest_sys_upd2 as on update to rtest_system do
        update rtest_admin set sysname = new.sysname
-               where sysname = current.sysname;
-QUERY: create rule rtest_sys_del1 as on delete to rtest_system do
+               where sysname = current.sysname
+       );
+QUERY: create rule rtest_sys_del as on delete to rtest_system do (
        delete from rtest_interface where sysname = current.sysname;
-QUERY: create rule rtest_sys_del2 as on delete to rtest_system do
        delete from rtest_admin where sysname = current.sysname;
+       );
 QUERY: create rule rtest_pers_upd as on update to rtest_person do
        update rtest_admin set pname = new.pname where pname = current.pname;
 QUERY: create rule rtest_pers_del as on delete to rtest_person do
index 433e07a3a909d6612fdbf30917d32dc3a2969bbb..3e63ef584957102665c5e42c8683f77f2c5b17ac 100644 (file)
@@ -24,26 +24,26 @@ create rule rtest_v1_del as on delete to rtest_v1 do instead
 -- Tables and rules for the constraint update/delete test
 --
 -- Note:
---     psql prevents from putting colons into brackets as
---     required for multi action rules. So we define single
---     rules for each action required for now
+--     Now that we have multiple action rule support, we check
+--     both possible syntaxes to define them (The last action
+--  can but must not have a semicolon at the end).
 --
 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_upd1 as on update to rtest_system do 
+create rule rtest_sys_upd as on update to rtest_system do (
        update rtest_interface set sysname = new.sysname 
                where sysname = current.sysname;
-create rule rtest_sys_upd2 as on update to rtest_system do 
        update rtest_admin set sysname = new.sysname 
-               where sysname = current.sysname;
+               where sysname = current.sysname
+       );
 
-create rule rtest_sys_del1 as on delete to rtest_system do
+create rule rtest_sys_del as on delete to rtest_system do (
        delete from rtest_interface where sysname = current.sysname;
-create rule rtest_sys_del2 as on delete to rtest_system do
        delete from rtest_admin where sysname = current.sysname;
+       );
 
 create rule rtest_pers_upd as on update to rtest_person do 
        update rtest_admin set pname = new.pname where pname = current.pname;