Stephan Szabo wrote:
> On Wed, 7 Dec 2005, Bruce Momjian wrote:
>
> > I had an open 8.1 item that was:
> >
> > o fix foreign trigger timing issue
> >
> > Would someone supply text for a TODO entry on this, as I don't think we
> > fixed it in 8.1.
>
> I'd split this into two separate items now.
>
> Fix before delete triggers on cascaded deletes to run after the cascaded
> delete is done. This is odd, but seems to be what the spec requires.
>
> Fix problems with referential action caused before triggers that modify
> rows that would also be modified by the referential action. Right now,
> this has a few symptoms, either you can get spurious seeming errors from
> the constraint or you can end up with invalid data in the referencing
> table. As far as I can see, the spec doesn't have much to say about this
> because the spec doesn't seem to allow before triggers to modify tables.
I have updated the CREATE TRIGGER documentation to highlight these
items, and the fact we consider our current behavior on the first item
to be correct.
--
Bruce Momjian | http://candle.pha.pa.us
[email protected] | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
Index: doc/src/sgml/ref/create_trigger.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/ref/create_trigger.sgml,v
retrieving revision 1.42
diff -c -c -r1.42 create_trigger.sgml
*** doc/src/sgml/ref/create_trigger.sgml 1 Nov 2005 21:09:50 -0000
1.42
--- doc/src/sgml/ref/create_trigger.sgml 9 Dec 2005 19:38:27 -0000
***************
*** 241,253 ****
function that executes the desired commands.
</para>
</listitem>
</itemizedlist>
</para>
<para>
SQL specifies that multiple triggers should be fired in
time-of-creation order. <productname>PostgreSQL</productname> uses
! name order, which was judged more convenient to work with.
</para>
<para>
--- 241,265 ----
function that executes the desired commands.
</para>
</listitem>
+
</itemizedlist>
</para>
<para>
SQL specifies that multiple triggers should be fired in
time-of-creation order. <productname>PostgreSQL</productname> uses
! name order, which was judged to be more convenient.
! </para>
!
! <para>
! SQL specifies that <literal>BEFORE DELETE</literal> triggers on cascaded
! deletes fire <emphasis>after</> the cascaded <literal>DELETE</> completes.
! The <productname>PostgreSQL</productname> behavior is for <literal>BEFORE
! DELETE</literal> to always fire before the delete action, even a cascading
! one. This is considered more consistent. There is also unpredictable
! behavior when <literal>BEFORE</literal> triggers modify rows that are later
! to be modified by referential actions. This can lead to contraint
violations
! or stored data that does not honor the referential constraint.
</para>
<para>
---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings