diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-03-28 00:21:56 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-03-28 00:21:56 +0000 |
commit | 7692d8d5b72f510bd84f708d0a8e53c548f71adc (patch) | |
tree | 2db349ab412c7353734bfd232fbba8c5261913a0 /doc/src/sgml/ref | |
parent | 107b3d0c23b52cf20b705d00200211d8cc341f52 (diff) |
Support statement-level ON TRUNCATE triggers. Simon Riggs
Diffstat (limited to 'doc/src/sgml/ref')
-rw-r--r-- | doc/src/sgml/ref/create_trigger.sgml | 38 | ||||
-rw-r--r-- | doc/src/sgml/ref/truncate.sgml | 16 |
2 files changed, 37 insertions, 17 deletions
diff --git a/doc/src/sgml/ref/create_trigger.sgml b/doc/src/sgml/ref/create_trigger.sgml index 9cbdcf91651..13079815667 100644 --- a/doc/src/sgml/ref/create_trigger.sgml +++ b/doc/src/sgml/ref/create_trigger.sgml @@ -1,5 +1,5 @@ <!-- -$PostgreSQL: pgsql/doc/src/sgml/ref/create_trigger.sgml,v 1.47 2007/02/01 19:10:24 momjian Exp $ +$PostgreSQL: pgsql/doc/src/sgml/ref/create_trigger.sgml,v 1.48 2008/03/28 00:21:55 tgl Exp $ PostgreSQL documentation --> @@ -25,7 +25,7 @@ CREATE TRIGGER <replaceable class="PARAMETER">name</replaceable> { BEFORE | AFTE EXECUTE PROCEDURE <replaceable class="PARAMETER">funcname</replaceable> ( <replaceable class="PARAMETER">arguments</replaceable> ) </synopsis> </refsynopsisdiv> - + <refsect1> <title>Description</title> @@ -66,6 +66,12 @@ CREATE TRIGGER <replaceable class="PARAMETER">name</replaceable> { BEFORE | AFTE </para> <para> + In addition, triggers may be defined to fire for a + <command>TRUNCATE</command>, though only + <literal>FOR EACH STATEMENT</literal>. + </para> + + <para> If multiple triggers of the same kind are defined for the same event, they will be fired in alphabetical order by name. </para> @@ -80,7 +86,7 @@ CREATE TRIGGER <replaceable class="PARAMETER">name</replaceable> { BEFORE | AFTE Refer to <xref linkend="triggers"> for more information about triggers. </para> </refsect1> - + <refsect1> <title>Parameters</title> @@ -110,10 +116,10 @@ CREATE TRIGGER <replaceable class="PARAMETER">name</replaceable> { BEFORE | AFTE <term><replaceable class="parameter">event</replaceable></term> <listitem> <para> - One of <command>INSERT</command>, <command>UPDATE</command>, or - <command>DELETE</command>; this specifies the event that will - fire the trigger. Multiple events can be specified using - <literal>OR</literal>. + One of <command>INSERT</command>, <command>UPDATE</command>, + <command>DELETE</command>, or <command>TRUNCATE</command>; + this specifies the event that will fire the trigger. Multiple + events can be specified using <literal>OR</literal>. </para> </listitem> </varlistentry> @@ -180,6 +186,11 @@ CREATE TRIGGER <replaceable class="PARAMETER">name</replaceable> { BEFORE | AFTE </para> <para> + Use <xref linkend="sql-droptrigger" + endterm="sql-droptrigger-title"> to remove a trigger. + </para> + + <para> In <productname>PostgreSQL</productname> versions before 7.3, it was necessary to declare trigger functions as returning the placeholder type <type>opaque</>, rather than <type>trigger</>. To support loading @@ -187,11 +198,6 @@ CREATE TRIGGER <replaceable class="PARAMETER">name</replaceable> { BEFORE | AFTE declared as returning <type>opaque</>, but it will issue a notice and change the function's declared return type to <type>trigger</>. </para> - - <para> - Use <xref linkend="sql-droptrigger" - endterm="sql-droptrigger-title"> to remove a trigger. - </para> </refsect1> <refsect1 id="R1-SQL-CREATETRIGGER-2"> @@ -204,7 +210,7 @@ CREATE TRIGGER <replaceable class="PARAMETER">name</replaceable> { BEFORE | AFTE <refsect1 id="SQL-CREATETRIGGER-compatibility"> <title>Compatibility</title> - + <para> The <command>CREATE TRIGGER</command> statement in <productname>PostgreSQL</productname> implements a subset of the @@ -267,6 +273,12 @@ CREATE TRIGGER <replaceable class="PARAMETER">name</replaceable> { BEFORE | AFTE <literal>OR</literal> is a <productname>PostgreSQL</> extension of the SQL standard. </para> + + <para> + The ability to fire triggers for <command>TRUNCATE</command> is a + <productname>PostgreSQL</> extension of the SQL standard. + </para> + </refsect1> <refsect1> diff --git a/doc/src/sgml/ref/truncate.sgml b/doc/src/sgml/ref/truncate.sgml index 3dca068b457..486a2d3e992 100644 --- a/doc/src/sgml/ref/truncate.sgml +++ b/doc/src/sgml/ref/truncate.sgml @@ -1,5 +1,5 @@ <!-- -$PostgreSQL: pgsql/doc/src/sgml/ref/truncate.sgml,v 1.24 2007/05/11 19:40:08 neilc Exp $ +$PostgreSQL: pgsql/doc/src/sgml/ref/truncate.sgml,v 1.25 2008/03/28 00:21:55 tgl Exp $ PostgreSQL documentation --> @@ -36,7 +36,7 @@ TRUNCATE [ TABLE ] <replaceable class="PARAMETER">name</replaceable> [, ...] [ C operation. This is most useful on large tables. </para> </refsect1> - + <refsect1> <title>Parameters</title> @@ -91,8 +91,16 @@ TRUNCATE [ TABLE ] <replaceable class="PARAMETER">name</replaceable> [, ...] [ C </para> <para> - <command>TRUNCATE</> will not run any <literal>ON DELETE</literal> - triggers that might exist for the tables. + <command>TRUNCATE</> will not fire any <literal>ON DELETE</literal> + triggers that might exist for the tables. But it will fire + <literal>ON TRUNCATE</literal> triggers. + If <literal>ON TRUNCATE</> triggers are defined for any of + the tables, then all <literal>BEFORE TRUNCATE</literal> triggers are + fired before any truncation happens, and all <literal>AFTER + TRUNCATE</literal> triggers are fired after the last truncation is + performed. The triggers will fire in the order that the tables are + to be processed (first those listed in the command, and then any + that were added due to cascading). </para> <warning> |