Re: AFTER triggers and constraints

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: David Greco <David_Greco(at)harte-hanks(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: AFTER triggers and constraints
Date: 2013-06-28 14:10:12
Message-ID: 7609.1372428612@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

David Greco <David_Greco(at)harte-hanks(dot)com> writes:
> Since the trigger is defined as AFTER ROW, versus AFTER STATEMENT, I believe the trigger should be considered part of the statement, therefore the constraint should not be checked until after the row triggers have run. Any thoughts?

Not sure that this is terribly well documented, but you can arrange for
your triggers to fire before the FK-enforcement triggers. Triggers on
the same table and event type fire in alphabetical (in ASCII) order, so
just choose a name that's before the FK triggers, which if memory serves
have names starting with "RI_". So for instance
CREATE TRIGGER "Parent_ar_trg" ...
would have worked the way you want.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Greco 2013-06-28 15:09:12 Re: AFTER triggers and constraints
Previous Message David Greco 2013-06-28 13:37:45 Re: AFTER triggers and constraints