aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Wieck <JanWieck@Yahoo.com>1999-02-07 19:02:20 +0000
committerJan Wieck <JanWieck@Yahoo.com>1999-02-07 19:02:20 +0000
commit28fc5d7b8312722a602b4a6afb023585e3c34b6d (patch)
tree7397f555de9c812cbb001dd286a3616d56e6f48c /src
parentef590e101ec2e7fd4d2c80b925ce2188aa000bba (diff)
downloadpostgresql-28fc5d7b8312722a602b4a6afb023585e3c34b6d.tar.gz
postgresql-28fc5d7b8312722a602b4a6afb023585e3c34b6d.zip
Reenabled parentheses for grouping multiple rule actions and
added this syntax to rules regression test so it will show up if someone breaks it again. Jan
Diffstat (limited to 'src')
-rw-r--r--src/backend/parser/gram.y45
-rw-r--r--src/test/regress/expected/rules.out10
-rw-r--r--src/test/regress/sql/rules.sql16
3 files changed, 34 insertions, 37 deletions
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index b29f76420fa..e88b9073084 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -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);
diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.out
index c45ae096510..448551e54de 100644
--- a/src/test/regress/expected/rules.out
+++ b/src/test/regress/expected/rules.out
@@ -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
diff --git a/src/test/regress/sql/rules.sql b/src/test/regress/sql/rules.sql
index 433e07a3a90..3e63ef58495 100644
--- a/src/test/regress/sql/rules.sql
+++ b/src/test/regress/sql/rules.sql
@@ -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;