mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-24 18:55:04 +08:00
Update man page to prefer old over current.
This commit is contained in:
parent
52f77df613
commit
2a08204e1f
@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_rule.sgml,v 1.14 2000/04/07 19:17:30 momjian Exp $
|
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_rule.sgml,v 1.15 2000/04/12 20:07:13 momjian Exp $
|
||||||
Postgres documentation
|
Postgres documentation
|
||||||
-->
|
-->
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ CREATE RULE <replaceable class="parameter">name</replaceable> AS ON <replaceable
|
|||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Any SQL WHERE clause, <literal>new</literal> or
|
Any SQL WHERE clause, <literal>new</literal> or
|
||||||
<literal>current</literal> can appear instead of an instance
|
<literal>old</literal> can appear instead of an instance
|
||||||
variable whenever an instance variable is permissible in SQL.
|
variable whenever an instance variable is permissible in SQL.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
@ -81,7 +81,7 @@ CREATE RULE <replaceable class="parameter">name</replaceable> AS ON <replaceable
|
|||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Any SQL statement, <literal>new</literal> or
|
Any SQL statement, <literal>new</literal> or
|
||||||
<literal>current</literal> can appear instead of an instance
|
<literal>old</literal> can appear instead of an instance
|
||||||
variable whenever an instance variable is permissible in SQL.
|
variable whenever an instance variable is permissible in SQL.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
@ -133,17 +133,17 @@ CREATE
|
|||||||
|
|
||||||
<para>
|
<para>
|
||||||
The semantics of a rule is that at the time an individual instance is
|
The semantics of a rule is that at the time an individual instance is
|
||||||
accessed, inserted, updated, or deleted, there is a current instance (for
|
accessed, inserted, updated, or deleted, there is a old instance (for
|
||||||
selects, updates and deletes) and a new instance (for inserts and
|
selects, updates and deletes) and a new instance (for inserts and
|
||||||
updates).
|
updates).
|
||||||
If the <replaceable class="parameter">event</replaceable>
|
If the <replaceable class="parameter">event</replaceable>
|
||||||
specified in the ON clause and the
|
specified in the ON clause and the
|
||||||
<replaceable class="parameter">condition</replaceable> specified in the
|
<replaceable class="parameter">condition</replaceable> specified in the
|
||||||
WHERE clause are true for the current instance, the
|
WHERE clause are true for the old instance, the
|
||||||
<replaceable class="parameter">action</replaceable> part of the rule is
|
<replaceable class="parameter">action</replaceable> part of the rule is
|
||||||
executed. First, however, values from fields in the current instance
|
executed. First, however, values from fields in the old instance
|
||||||
and/or the new instance are substituted for
|
and/or the new instance are substituted for
|
||||||
<literal>current.</literal><replaceable class="parameter">attribute-name</replaceable>
|
<literal>old.</literal><replaceable class="parameter">attribute-name</replaceable>
|
||||||
and <literal>new.</literal><replaceable class="parameter">attribute-name</replaceable>.
|
and <literal>new.</literal><replaceable class="parameter">attribute-name</replaceable>.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -167,7 +167,7 @@ CREATE
|
|||||||
<replaceable class="parameter">condition</replaceable> and
|
<replaceable class="parameter">condition</replaceable> and
|
||||||
<replaceable class="parameter">action</replaceable> parts of a rule,
|
<replaceable class="parameter">action</replaceable> parts of a rule,
|
||||||
they are all considered different tuple variables. More accurately,
|
they are all considered different tuple variables. More accurately,
|
||||||
<literal>new</literal> and <literal>current</literal> are the only tuple
|
<literal>new</literal> and <literal>old</literal> are the only tuple
|
||||||
variables that are shared between these clauses. For example, the following
|
variables that are shared between these clauses. For example, the following
|
||||||
two rules have the same semantics:
|
two rules have the same semantics:
|
||||||
<programlisting>
|
<programlisting>
|
||||||
@ -263,7 +263,7 @@ SELECT * FROM emp;
|
|||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
CREATE RULE example_1 AS
|
CREATE RULE example_1 AS
|
||||||
ON UPDATE emp.salary WHERE current.name = "Joe"
|
ON UPDATE emp.salary WHERE old.name = "Joe"
|
||||||
DO
|
DO
|
||||||
UPDATE emp
|
UPDATE emp
|
||||||
SET salary = new.salary
|
SET salary = new.salary
|
||||||
@ -271,7 +271,7 @@ CREATE RULE example_1 AS
|
|||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
At the time Joe receives a salary adjustment, the event
|
At the time Joe receives a salary adjustment, the event
|
||||||
will become true and Joe's current instance and proposed
|
will become true and Joe's old instance and proposed
|
||||||
new instance are available to the execution routines.
|
new instance are available to the execution routines.
|
||||||
Hence, his new salary is substituted into the action part
|
Hence, his new salary is substituted into the action part
|
||||||
of the rule which is subsequently executed. This propagates
|
of the rule which is subsequently executed. This propagates
|
||||||
@ -282,7 +282,7 @@ CREATE RULE example_1 AS
|
|||||||
<programlisting>
|
<programlisting>
|
||||||
CREATE RULE example_2 AS
|
CREATE RULE example_2 AS
|
||||||
ON SELECT TO EMP.salary
|
ON SELECT TO EMP.salary
|
||||||
WHERE current.name = "Bill"
|
WHERE old.name = "Bill"
|
||||||
DO INSTEAD
|
DO INSTEAD
|
||||||
SELECT emp.salary
|
SELECT emp.salary
|
||||||
FROM emp
|
FROM emp
|
||||||
@ -297,7 +297,7 @@ CREATE RULE example_2 AS
|
|||||||
CREATE RULE example_3 AS
|
CREATE RULE example_3 AS
|
||||||
ON
|
ON
|
||||||
SELECT TO emp.salary
|
SELECT TO emp.salary
|
||||||
WHERE current.dept = "shoe" AND current_user = "Joe"
|
WHERE old.dept = "shoe" AND current_user = "Joe"
|
||||||
DO INSTEAD NOTHING;
|
DO INSTEAD NOTHING;
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
Loading…
Reference in New Issue
Block a user