11<!--
2- $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_rule.sgml,v 1.13 2000/04/07 17:37:24 momjian Exp $
2+ $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_rule.sgml,v 1.14 2000/04/0719: 17:30 momjian Exp $
33Postgres documentation
44-->
55
@@ -126,16 +126,17 @@ CREATE
126126 <para>
127127 The <productname>Postgres</productname>
128128 <firstterm>rule system</firstterm> allows one to define an
129- alternate action to be performed onupdates, inserts , or deletions
129+ alternate action to be performed oninserts, updates , or deletions
130130 from database tables or classes. Currently, rules are used to
131131 implement table views.
132132 </para>
133133
134134 <para>
135135 The semantics of a rule is that at the time an individual instance is
136- accessed, updated, inserted or deleted, there is a current instance (for
137- retrieves, updates and deletes) and a new instance (for updates and
138- appends). If the <replaceable class="parameter">event</replaceable>
136+ accessed, inserted, updated, or deleted, there is a current instance (for
137+ selects, updates and deletes) and a new instance (for inserts and
138+ updates).
139+ If the <replaceable class="parameter">event</replaceable>
139140 specified in the ON clause and the
140141 <replaceable class="parameter">condition</replaceable> specified in the
141142 WHERE clause are true for the current instance, the
@@ -162,8 +163,8 @@ CREATE
162163 <para>
163164 A caution about SQL rules is in order. If the same class name
164165 or instance variable appears in the
165- <replaceable class="parameter">event</replaceable>, the
166- <replaceable class="parameter">condition</replaceable> and the
166+ <replaceable class="parameter">event</replaceable>,
167+ <replaceable class="parameter">condition</replaceable> and
167168 <replaceable class="parameter">action</replaceable> parts of a rule,
168169 they are all considered different tuple variables. More accurately,
169170 <literal>new</literal> and <literal>current</literal> are the only tuple
@@ -172,13 +173,13 @@ CREATE
172173 <programlisting>
173174ON UPDATE TO emp.salary WHERE emp.name = "Joe"
174175 DO
175- UPDATE emp( ... ) WHERE ...
176+ UPDATE empSET ... WHERE ...
176177 </programlisting>
177178
178179 <programlisting>
179180ON UPDATE TO emp-1.salary WHERE emp-2.name = "Joe"
180181 DO
181- UPDATE emp-3( ...) WHERE ...
182+ UPDATE emp-3SET ... WHERE ...
182183 </programlisting>
183184
184185 Each rule can have the optional tag INSTEAD.
@@ -194,11 +195,12 @@ ON UPDATE TO emp-1.salary WHERE emp-2.name = "Joe"
194195 <literal>NOTHING</literal>.
195196 </para>
196197 <para>
197- It is very important to notethat the rewrite rule system
198- will neither detect nor process circular rules. For example, though each
198+ It is very important to noteto avoid circular rules.
199+ For example, though each
199200 of the following two rule definitions are accepted by
200201 <productname>Postgres</productname>, the
201- retrieve command will cause <productname>Postgres</productname> to crash:
202+ select command will cause <productname>Postgres</productname> to
203+ report an error because the query cycled too many times:
202204
203205 <example>
204206 <title>Example of a circular rewrite rule combination.</title>
@@ -216,8 +218,9 @@ CREATE RULE bad_rule_combination_2 AS
216218SELECT TO emp;
217219 </programlisting>
218220 <para>
219- This attempt to retrieve from EMP will cause
220- <productname>Postgres</productname> to crash.
221+ This attempt to select from EMP will cause
222+ <productname>Postgres</productname> to issue an error
223+ because the queries cycled too many times.
221224 <programlisting>
222225SELECT * FROM emp;
223226 </programlisting></para>
@@ -306,7 +309,7 @@ CREATE toyemp(name = char16, salary = int4);
306309CREATE RULE example_4 AS
307310 ON SELECT TO toyemp
308311 DO INSTEAD
309- SELECT( emp.name, emp.salary)
312+ SELECT emp.name, emp.salary
310313FROM emp
311314 WHERE emp.dept = "toy";
312315 </programlisting>
@@ -317,7 +320,7 @@ CREATE RULE example_4 AS
317320CREATE RULE example_5 AS
318321 ON INERT TO emp WHERE new.salary > 5000
319322 DO
320- UPDATE NEWSET salary = 5000;
323+ UPDATE NEWSETSET salary = 5000;
321324 </programlisting>
322325 </para>
323326 </refsect1>