diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2004-09-10 18:40:09 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2004-09-10 18:40:09 +0000 |
commit | b339d1fff6c2f14776af29a35c8550b222ca70b2 (patch) | |
tree | be0ed19fa78e35cdde627d1c6bc4c4be9f7cb44e /doc/src | |
parent | 856d1faac1024717b7c37665c46fd635dc52b1b4 (diff) | |
download | postgresql-b339d1fff6c2f14776af29a35c8550b222ca70b2.tar.gz postgresql-b339d1fff6c2f14776af29a35c8550b222ca70b2.zip |
Fire non-deferred AFTER triggers immediately upon query completion,
rather than when returning to the idle loop. This makes no particular
difference for interactively-issued queries, but it makes a big difference
for queries issued within functions: trigger execution now occurs before
the calling function is allowed to proceed. This responds to numerous
complaints about nonintuitive behavior of foreign key checking, such as
http://archives.postgresql.org/pgsql-bugs/2004-09/msg00020.php, and
appears to be required by the SQL99 spec.
Also take the opportunity to simplify the data structures used for the
pending-trigger list, rename them for more clarity, and squeeze out a
bit of space.
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/ref/set_constraints.sgml | 31 | ||||
-rw-r--r-- | doc/src/sgml/release.sgml | 26 |
2 files changed, 39 insertions, 18 deletions
diff --git a/doc/src/sgml/ref/set_constraints.sgml b/doc/src/sgml/ref/set_constraints.sgml index 0c976c93e25..3bcde91f386 100644 --- a/doc/src/sgml/ref/set_constraints.sgml +++ b/doc/src/sgml/ref/set_constraints.sgml @@ -1,4 +1,4 @@ -<!-- $PostgreSQL: pgsql/doc/src/sgml/ref/set_constraints.sgml,v 1.11 2004/09/08 20:47:37 tgl Exp $ --> +<!-- $PostgreSQL: pgsql/doc/src/sgml/ref/set_constraints.sgml,v 1.12 2004/09/10 18:39:53 tgl Exp $ --> <refentry id="SQL-SET-CONSTRAINTS"> <refmeta> <refentrytitle id="SQL-SET-CONSTRAINTS-title">SET CONSTRAINTS</refentrytitle> @@ -34,13 +34,13 @@ SET CONSTRAINTS { ALL | <replaceable class="parameter">name</replaceable> [, ... <para> Upon creation, a constraint is given one of three - characteristics: <literal>INITIALLY DEFERRED</literal>, - <literal>INITIALLY IMMEDIATE DEFERRABLE</literal>, or - <literal>INITIALLY IMMEDIATE NOT DEFERRABLE</literal>. The third - class is not affected by the <command>SET CONSTRAINTS</command> - command. The first two classes start every transaction in the - indicated mode, but their behavior can be changed within a transaction - by <command>SET CONSTRAINTS</command>. + characteristics: <literal>DEFERRABLE INITIALLY DEFERRED</literal>, + <literal>DEFERRABLE INITIALLY IMMEDIATE</literal>, or + <literal>NOT DEFERRABLE</literal>. The third + class is always <literal>IMMEDIATE</literal> and is not affected by the + <command>SET CONSTRAINTS</command> command. The first two classes start + every transaction in the indicated mode, but their behavior can be changed + within a transaction by <command>SET CONSTRAINTS</command>. </para> <para> @@ -52,19 +52,22 @@ SET CONSTRAINTS { ALL | <replaceable class="parameter">name</replaceable> [, ... </para> <para> - When you change the mode of a constraint from <literal>DEFERRED</literal> + When <command>SET CONSTRAINTS</command> changes the mode of a constraint + from <literal>DEFERRED</literal> to <literal>IMMEDIATE</literal>, the new mode takes effect retroactively: any outstanding data modifications that would have been checked at the end of the transaction are instead checked during the execution of the <command>SET CONSTRAINTS</command> command. If any such constraint is violated, the <command>SET CONSTRAINTS</command> - fails (and does not change the constraint mode). + fails (and does not change the constraint mode). Thus, <command>SET + CONSTRAINTS</command> can be used to force checking of constraints to + occur at a specific point in a transaction. </para> <para> Currently, only foreign key constraints are affected by this setting. Check and unique constraints are always effectively - initially immediate not deferrable. + not deferrable. </para> </refsect1> @@ -76,11 +79,7 @@ SET CONSTRAINTS { ALL | <replaceable class="parameter">name</replaceable> [, ... current transaction. Thus, if you execute this command outside of a transaction block (<command>BEGIN</command>/<command>COMMIT</command> pair), it will - not appear to have any effect. If you wish to change the behavior - of a constraint without needing to issue a <command>SET - CONSTRAINTS</command> command in every transaction, specify - <literal>INITIALLY DEFERRED</literal> or <literal>INITIALLY - IMMEDIATE</literal> when you create the constraint. + not appear to have any effect. </para> </refsect1> diff --git a/doc/src/sgml/release.sgml b/doc/src/sgml/release.sgml index b742f675e30..ddf93a04ff9 100644 --- a/doc/src/sgml/release.sgml +++ b/doc/src/sgml/release.sgml @@ -1,5 +1,5 @@ <!-- -$PostgreSQL: pgsql/doc/src/sgml/release.sgml,v 1.294 2004/08/30 00:47:31 tgl Exp $ +$PostgreSQL: pgsql/doc/src/sgml/release.sgml,v 1.295 2004/09/10 18:39:54 tgl Exp $ --> <appendix id="release"> @@ -336,6 +336,16 @@ $PostgreSQL: pgsql/doc/src/sgml/release.sgml,v 1.294 2004/08/30 00:47:31 tgl Exp whitespace (which has always been ignored). </para> </listitem> + + <listitem> + <para> + Non-deferred AFTER triggers are now fired immediately after completion + of the triggering query, rather than upon finishing the current + interactive command. This makes a difference when the triggering query + occurred within a function: the trigger is invoked before the function + proceeds to its next operation. + </para> + </listitem> </itemizedlist> </para> </sect2> @@ -1426,6 +1436,18 @@ $PostgreSQL: pgsql/doc/src/sgml/release.sgml,v 1.294 2004/08/30 00:47:31 tgl Exp <listitem> <para> + Non-deferred AFTER triggers are now fired immediately after completion + of the triggering query, rather than upon finishing the current + interactive command. This makes a difference when the triggering query + occurred within a function: the trigger is invoked before the function + proceeds to its next operation. For example, if a function inserts + a new row into a table, any non-deferred foreign key checks occur + before proceeding with the function. + </para> + </listitem> + + <listitem> + <para> Allow function parameters to be declared with names (Dennis Bjorklund) </para> <para> @@ -1483,7 +1505,7 @@ $PostgreSQL: pgsql/doc/src/sgml/release.sgml,v 1.294 2004/08/30 00:47:31 tgl Exp <listitem> <para> - New plperl server-side language (Command Prompt, Andrew Dunstan) + Major overhaul of plperl server-side language (Command Prompt, Andrew Dunstan) </para> </listitem> |