Re: Cascades Failing - Mailing list pgsql-general

From Tom Lane
Subject Re: Cascades Failing
Date
Msg-id 849.1124202850@sss.pgh.pa.us
Whole thread Raw
In response to Re: Cascades Failing  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
List pgsql-general
Stephan Szabo <sszabo@megazone.bigpanda.com> writes:
> I think this is similar to the issue recently reported on -bugs.  My
> theory there was that trigger timing changes between 7.4 and 8.0 seems to
> have caused the sequence of checks inside the trigger manager and triggers
> that prevented intermediate states from being checked to become broken.

Just looking at the example, I think that the issue is that we fire a
trigger for one of the FK constraints, it does an UPDATE to fix the
constraint it knows about, and then on the way out of that UPDATE
statement, check triggers for all of the FK constraints are executed
and the ones that haven't been fixed yet are unhappy.  (The failure
occurs because two independent updates are needed on the same row of
the referencing table, and only one has been done yet.)  So the problem
comes directly from the fact that FK triggers can fire at the ends of
nested statements, rather than only at the outer level as they did
before.

This suggests that we need a way to prevent immediate execution of
freshly queued triggers at the end of a command fired by an FK trigger.
If we could move them to the end of the trigger queue that the FK
operation itself is in, things would work reasonably well I think.

            regards, tom lane

pgsql-general by date:

Previous
From: "Andrus"
Date:
Subject: Prevent inserting document without rows
Next
From: Matt Miller
Date:
Subject: Re: Prevent inserting document without rows