Commit 47110ace authored by Neil Conway's avatar Neil Conway

Add documentation for the recent 'ALSO' patch for CREATE RULE. Along

the way, fix a typo and make a few SGML cleanups.
parent f31a43f9
<!-- <!--
$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 ...@@ -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>
...@@ -111,7 +111,7 @@ CREATE [ OR REPLACE ] RULE <replaceable class="parameter">name</replaceable> AS ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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; ...@@ -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; ...@@ -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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment