Add documentation for the recent 'ALSO' patch for CREATE RULE. Along
the way, fix a typo and make a few SGML cleanups.
This commit is contained in:
parent
f31a43f9ae
commit
47110ace3a
@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
$PostgreSQL: pgsql/doc/src/sgml/ref/create_rule.sgml,v 1.43 2004/03/04 14:32:12 momjian Exp $
|
$PostgreSQL: pgsql/doc/src/sgml/ref/create_rule.sgml,v 1.44 2004/03/09 19:30:21 neilc Exp $
|
||||||
PostgreSQL documentation
|
PostgreSQL documentation
|
||||||
-->
|
-->
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ PostgreSQL documentation
|
|||||||
<synopsis>
|
<synopsis>
|
||||||
CREATE [ OR REPLACE ] RULE <replaceable class="parameter">name</replaceable> AS ON <replaceable class="parameter">event</replaceable>
|
CREATE [ OR REPLACE ] RULE <replaceable class="parameter">name</replaceable> AS ON <replaceable class="parameter">event</replaceable>
|
||||||
TO <replaceable class="parameter">table</replaceable> [ WHERE <replaceable class="parameter">condition</replaceable> ]
|
TO <replaceable class="parameter">table</replaceable> [ WHERE <replaceable class="parameter">condition</replaceable> ]
|
||||||
DO [ INSTEAD ] { NOTHING | <replaceable class="parameter">command</replaceable> | ( <replaceable class="parameter">command</replaceable> ; <replaceable class="parameter">command</replaceable> ... ) }
|
DO [ ALSO | INSTEAD ] { NOTHING | <replaceable class="parameter">command</replaceable> | ( <replaceable class="parameter">command</replaceable> ; <replaceable class="parameter">command</replaceable> ... ) }
|
||||||
</synopsis>
|
</synopsis>
|
||||||
</refsynopsisdiv>
|
</refsynopsisdiv>
|
||||||
|
|
||||||
@ -43,13 +43,13 @@ CREATE [ OR REPLACE ] RULE <replaceable class="parameter">name</replaceable> AS
|
|||||||
or deletions in database tables. Roughly speaking, a rule causes
|
or deletions in database tables. Roughly speaking, a rule causes
|
||||||
additional commands to be executed when a given command on a given
|
additional commands to be executed when a given command on a given
|
||||||
table is executed. Alternatively, an <literal>INSTEAD</literal>
|
table is executed. Alternatively, an <literal>INSTEAD</literal>
|
||||||
rule can replace a given command by another, or cause a command
|
rule can replace a given command by another, or cause a command
|
||||||
not to be executed at all. Rules are used to implement table
|
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
|
views as well. It is important to realize that a rule is really
|
||||||
a command transformation mechanism, or command macro. The
|
a command transformation mechanism, or command macro. The
|
||||||
transformation happens before the execution of the commands starts.
|
transformation happens before the execution of the commands starts.
|
||||||
If you actually want an operation that fires independently for each
|
If you actually want an operation that fires independently for each
|
||||||
physical row, you probably want to use a trigger, not a rule.
|
physical row, you probably want to use a trigger, not a rule.
|
||||||
More information about the rules system is in <xref linkend="rules">.
|
More information about the rules system is in <xref linkend="rules">.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ CREATE [ OR REPLACE ] RULE <replaceable class="parameter">name</replaceable> AS
|
|||||||
<term><replaceable class="parameter">event</replaceable></term>
|
<term><replaceable class="parameter">event</replaceable></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
The even is one of <literal>SELECT</literal>,
|
The event is one of <literal>SELECT</literal>,
|
||||||
<literal>INSERT</literal>, <literal>UPDATE</literal>, or
|
<literal>INSERT</literal>, <literal>UPDATE</literal>, or
|
||||||
<literal>DELETE</literal>.
|
<literal>DELETE</literal>.
|
||||||
</para>
|
</para>
|
||||||
@ -132,10 +132,10 @@ CREATE [ OR REPLACE ] RULE <replaceable class="parameter">name</replaceable> AS
|
|||||||
<term><replaceable class="parameter">condition</replaceable></term>
|
<term><replaceable class="parameter">condition</replaceable></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Any SQL conditional expression (returning <type>boolean</type>).
|
Any <acronym>SQL</acronym> conditional expression (returning
|
||||||
The condition expression may not refer to any tables except
|
<type>boolean</type>). The condition expression may not refer
|
||||||
<literal>NEW</literal> and <literal>OLD</literal>, and may not
|
to any tables except <literal>NEW</> and <literal>OLD</>, and
|
||||||
contain aggregate functions.
|
may not contain aggregate functions.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
@ -145,8 +145,24 @@ CREATE [ OR REPLACE ] RULE <replaceable class="parameter">name</replaceable> AS
|
|||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
<literal>INSTEAD</literal> indicates that the commands should be
|
<literal>INSTEAD</literal> indicates that the commands should be
|
||||||
executed <emphasis>instead</> of the original command, not in
|
executed <emphasis>instead of</> the original command.
|
||||||
addition to the original command.
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>ALSO</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
<literal>ALSO</literal> indicates that the commands should be
|
||||||
|
executed <emphasis>in addition to</emphasis> the original
|
||||||
|
command.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
If neither <literal>ALSO</literal> nor
|
||||||
|
<literal>INSTEAD</literal> is specified, <literal>ALSO</literal>
|
||||||
|
is the default.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
@ -156,9 +172,9 @@ CREATE [ OR REPLACE ] RULE <replaceable class="parameter">name</replaceable> AS
|
|||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
The command or commands that make up the rule action. Valid
|
The command or commands that make up the rule action. Valid
|
||||||
commands are <literal>SELECT</literal>,
|
commands are <command>SELECT</command>,
|
||||||
<literal>INSERT</literal>, <literal>UPDATE</literal>,
|
<command>INSERT</command>, <command>UPDATE</command>,
|
||||||
<literal>DELETE</literal>, or <literal>NOTIFY</literal>.
|
<command>DELETE</command>, or <command>NOTIFY</command>.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
@ -215,14 +231,14 @@ SELECT * FROM t1;
|
|||||||
issued even if there are not any rows that the rule should apply
|
issued even if there are not any rows that the rule should apply
|
||||||
to. For example, in
|
to. For example, in
|
||||||
<programlisting>
|
<programlisting>
|
||||||
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;
|
UPDATE mytable SET name = 'foo' WHERE id = 42;
|
||||||
</programlisting>
|
</programlisting>
|
||||||
one <command>NOTIFY</command> event will be sent during the
|
one <command>NOTIFY</command> event will be sent during the
|
||||||
<command>UPDATE</command>, whether or not there are any rows with
|
<command>UPDATE</command>, whether or not there are any rows that
|
||||||
<literal>id = 42</literal>. This is an implementation restriction
|
match the condition <literal>id = 42</literal>. This is an
|
||||||
that may be fixed in future releases.
|
implementation restriction that may be fixed in future releases.
|
||||||
</para>
|
</para>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
@ -232,7 +248,7 @@ UPDATE mytable SET name = 'foo' WHERE id = 42;
|
|||||||
<para>
|
<para>
|
||||||
<command>CREATE RULE</command> is a
|
<command>CREATE RULE</command> is a
|
||||||
<productname>PostgreSQL</productname> language extension, as is the
|
<productname>PostgreSQL</productname> language extension, as is the
|
||||||
entire rules system.
|
entire query rewrite system.
|
||||||
</para>
|
</para>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
</refentry>
|
</refentry>
|
||||||
|
Loading…
Reference in New Issue
Block a user