*** ./doc/src/sgml/rules.sgml.orig Sun Feb 29 17:35:15 2004 --- ./doc/src/sgml/rules.sgml Sun Feb 29 17:38:45 2004 *************** *** 873,879 **** ! They can be INSTEAD or not. --- 873,879 ---- ! They can be INSTEAD or ALSO (default). *************** *** 904,910 **** CREATE RULE rule_name AS ON event TO object [WHERE rule_qualification] ! DO [INSTEAD] [action | (actions) | NOTHING]; in mind. --- 904,910 ---- CREATE RULE rule_name AS ON event TO object [WHERE rule_qualification] ! DO [ALSO|INSTEAD] [action | (actions) | NOTHING]; in mind. *************** *** 920,926 **** 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. --- 920,926 ---- 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 ALSO (default). *************** *** 937,943 **** ! No qualification and not INSTEAD the query tree from the rule action with the original query --- 937,943 ---- ! No qualification and ALSO the query tree from the rule action with the original query *************** *** 957,963 **** ! Qualification given and not INSTEAD the query tree from the rule action with the rule --- 957,963 ---- ! Qualification given and ALSO the query tree from the rule action with the rule *************** *** 980,986 **** ! Finally, if the rule is not INSTEAD, 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. --- 980,986 ---- ! 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,1117 **** ! The rule is a qualified non-INSTEAD 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: --- 1111,1117 ---- ! 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,1196 **** ! That's it. Since the rule is not INSTEAD, 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: --- 1190,1196 ---- ! 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: *** ./src/backend/parser/gram.y.orig Sun Feb 29 17:32:48 2004 --- ./src/backend/parser/gram.y Sun Feb 29 17:33:21 2004 *************** *** 327,333 **** /* 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 ASSERTION ASSIGNMENT AT AUTHORIZATION BACKWARD BEFORE BEGIN_P BETWEEN BIGINT BINARY BIT --- 327,333 ---- /* ordinary key words in alphabetical order */ %token ABORT_P ABSOLUTE_P ACCESS ACTION ADD AFTER ! AGGREGATE ALL ALSO ALTER ANALYSE ANALYZE AND ANY ARRAY AS ASC ASSERTION ASSIGNMENT AT AUTHORIZATION BACKWARD BEFORE BEGIN_P BETWEEN BIGINT BINARY BIT *************** *** 3529,3534 **** --- 3529,3535 ---- opt_instead: INSTEAD { $$ = TRUE; } + | ALSO { $$ = FALSE; } | /*EMPTY*/ { $$ = FALSE; } ; *** ./src/backend/parser/keywords.c.orig Sun Feb 29 17:29:44 2004 --- ./src/backend/parser/keywords.c Sun Feb 29 17:30:27 2004 *************** *** 38,43 **** --- 38,44 ---- {"after", AFTER}, {"aggregate", AGGREGATE}, {"all", ALL}, + {"also", ALSO}, {"alter", ALTER}, {"analyse", ANALYSE}, /* British spelling */ {"analyze", ANALYZE}, *** ./src/bin/psql/sql_help.h.orig Sun Feb 29 17:42:06 2004 --- ./src/bin/psql/sql_help.h Sun Feb 29 17:42:20 2004 *************** *** 159,165 **** { "CREATE RULE", N_("define a new rewrite rule"), ! N_("CREATE [ OR REPLACE ] RULE name AS ON event\n TO table [ WHERE condition ]\n DO [ INSTEAD ] { NOTHING | command | ( command ; command ... ) }") }, { "CREATE SCHEMA", N_("define a new schema"), --- 159,165 ---- { "CREATE RULE", N_("define a new rewrite rule"), ! N_("CREATE [ OR REPLACE ] RULE name AS ON event\n TO table [ WHERE condition ]\n DO [ ALSO | INSTEAD ] { NOTHING | command | ( command ; command ... ) }") }, { "CREATE SCHEMA", N_("define a new schema"), *** ./src/test/regress/expected/rules.out.orig Sun Feb 29 17:58:54 2004 --- ./src/test/regress/expected/rules.out Sun Feb 29 17:59:10 2004 *************** *** 29,47 **** 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 ( 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 ( 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 update rtest_admin set pname = new.pname where pname = old.pname; ! create rule rtest_pers_del as on delete to rtest_person do delete from rtest_admin where pname = old.pname; -- -- Tables and rules for the logging test --- 29,47 ---- 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 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 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 also update rtest_admin set pname = new.pname where pname = old.pname; ! 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 *** ./src/test/regress/sql/rules.sql.orig Sun Feb 29 17:43:59 2004 --- ./src/test/regress/sql/rules.sql Sun Feb 29 17:45:47 2004 *************** *** 33,54 **** 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 ( 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 ( 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 update rtest_admin set pname = new.pname where pname = old.pname; ! create rule rtest_pers_del as on delete to rtest_person do delete from rtest_admin where pname = old.pname; -- --- 33,54 ---- 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 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 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 also update rtest_admin set pname = new.pname where pname = old.pname; ! create rule rtest_pers_del as on delete to rtest_person do also delete from rtest_admin where pname = old.pname; -- *** ./doc/src/sgml/keywords.sgml.orig Sun Feb 29 18:44:44 2004 --- ./doc/src/sgml/keywords.sgml Sun Feb 29 18:45:40 2004 *************** *** 171,176 **** --- 171,182 ---- reserved + ALSO + non-reserved + + + + ALTER non-reserved reserved