From 47110ace3a9c58cbc887be8523d9b1818e1ba9c6 Mon Sep 17 00:00:00 2001 From: Neil Conway Date: Tue, 9 Mar 2004 19:30:21 +0000 Subject: [PATCH] Add documentation for the recent 'ALSO' patch for CREATE RULE. Along the way, fix a typo and make a few SGML cleanups. --- doc/src/sgml/ref/create_rule.sgml | 64 +++++++++++++++++++------------ 1 file changed, 40 insertions(+), 24 deletions(-) diff --git a/doc/src/sgml/ref/create_rule.sgml b/doc/src/sgml/ref/create_rule.sgml index 412ebcd66b..0ba20e3ce3 100644 --- a/doc/src/sgml/ref/create_rule.sgml +++ b/doc/src/sgml/ref/create_rule.sgml @@ -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, INSERT, UPDATE, 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 SELECT, - INSERT, UPDATE, - DELETE, or NOTIFY. + commands are SELECT, + INSERT, UPDATE, + 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. -- 2.40.0