aboutsummaryrefslogtreecommitdiff
path: root/doc/src/sgml/ref/create_constraint.sgml
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2009-11-20 20:38:12 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2009-11-20 20:38:12 +0000
commit7fc0f06221d22632daa3ff8b70919b43e8a242ca (patch)
treea2ec73a6256c30ba9cb2d4723868978c5136ba5e /doc/src/sgml/ref/create_constraint.sgml
parent201a45c4fa23c485cf2e14ac9db8064b2c559fdc (diff)
downloadpostgresql-7fc0f06221d22632daa3ff8b70919b43e8a242ca.tar.gz
postgresql-7fc0f06221d22632daa3ff8b70919b43e8a242ca.zip
Add a WHEN clause to CREATE TRIGGER, allowing a boolean expression to be
checked to determine whether the trigger should be fired. For BEFORE triggers this is mostly a matter of spec compliance; but for AFTER triggers it can provide a noticeable performance improvement, since queuing of a deferred trigger event and re-fetching of the row(s) at end of statement can be short-circuited if the trigger does not need to be fired. Takahiro Itagaki, reviewed by KaiGai Kohei.
Diffstat (limited to 'doc/src/sgml/ref/create_constraint.sgml')
-rw-r--r--doc/src/sgml/ref/create_constraint.sgml19
1 files changed, 18 insertions, 1 deletions
diff --git a/doc/src/sgml/ref/create_constraint.sgml b/doc/src/sgml/ref/create_constraint.sgml
index dbf4d679f2c..7da88318568 100644
--- a/doc/src/sgml/ref/create_constraint.sgml
+++ b/doc/src/sgml/ref/create_constraint.sgml
@@ -1,5 +1,5 @@
<!--
-$PostgreSQL: pgsql/doc/src/sgml/ref/create_constraint.sgml,v 1.20 2009/09/19 10:23:26 petere Exp $
+$PostgreSQL: pgsql/doc/src/sgml/ref/create_constraint.sgml,v 1.21 2009/11/20 20:38:09 tgl Exp $
PostgreSQL documentation
-->
@@ -27,6 +27,7 @@ CREATE CONSTRAINT TRIGGER <replaceable class="parameter">name</replaceable>
[ FROM <replaceable class="parameter">referenced_table_name</replaceable> ]
{ NOT DEFERRABLE | [ DEFERRABLE ] { INITIALLY IMMEDIATE | INITIALLY DEFERRED } }
FOR EACH ROW
+ [ WHEN ( <replaceable class="parameter">condition</replaceable> ) ]
EXECUTE PROCEDURE <replaceable class="parameter">function_name</replaceable> ( <replaceable class="parameter">arguments</replaceable> )
</synopsis>
</refsynopsisdiv>
@@ -110,6 +111,22 @@ CREATE CONSTRAINT TRIGGER <replaceable class="parameter">name</replaceable>
</varlistentry>
<varlistentry>
+ <term><replaceable class="parameter">condition</replaceable></term>
+ <listitem>
+ <para>
+ A Boolean expression that determines whether the trigger function
+ will actually be executed. This acts the same as in <xref
+ linkend="SQL-CREATETRIGGER" endterm="SQL-CREATETRIGGER-TITLE">.
+ Note in particular that evaluation of the <literal>WHEN</>
+ condition is not deferred, but occurs immediately after the row
+ update operation is performed. If the condition does not evaluate
+ to <literal>true</> then the trigger is not queued for deferred
+ execution.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><replaceable class="PARAMETER">function_name</replaceable></term>
<listitem>
<para>