Search Postgresql Archives

Re: AFTER triggers and constraints

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----Original Message-----
From: Tom Lane [mailto:tgl@xxxxxxxxxxxxx] 
Sent: Friday, June 28, 2013 10:10 AM
To: David Greco
Cc: pgsql-general@xxxxxxxxxxxxxx
Subject: Re:  AFTER triggers and constraints

David Greco <David_Greco@xxxxxxxxxxxxxxx> 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




Thanks Tom,

Yes, renaming the trigger does in fact work. Any thoughts on the theory of this behavior? i.e. is this ANSI compliant? Or should there be a mechanism in place that guarantees the FK-enforcement trigger runs after all others?





-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux