Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 97BC09FB5EA for ; Sat, 21 Apr 2007 13:20:47 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 99463-05 for ; Sat, 21 Apr 2007 13:20:45 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id B9D819FB3B2 for ; Sat, 21 Apr 2007 13:20:44 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id l3LGKeJk024566; Sat, 21 Apr 2007 12:20:40 -0400 (EDT) To: Michael Glaesemann cc: David Pufer , pgsql-docs@postgresql.org Subject: Re: Improving CREATE CONSTRAINT TRIGGER documentation - trigger firing order In-reply-to: References: <4629DBC8.4010700@7data.eu> Comments: In-reply-to Michael Glaesemann message dated "Sat, 21 Apr 2007 07:44:52 -0500" Date: Sat, 21 Apr 2007 12:20:40 -0400 Message-ID: <24565.1177172440@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/22 X-Sequence-Number: 4218 Michael Glaesemann writes: > On Apr 21, 2007, at 4:39 , David Pufer wrote: >> In my opinion it would be nice to mention in SQL reference commands that >> constraint triggers created by CREATE CONSTRAINT TRIGGER are fired in >> creation order unlike regular triggers created by command CREATE >> TRIGGER. As I know, the firing order of the CONSTRAINT TRIGGER is >> determined by the XXXXX num at "RI_ConstraintTrigger_XXXXX" column in >> pg_trigger table. > I believe this just falls out of the normal order of trigger firing > as explained in the CREATE TRIGGER documentation (http:// > www.postgresql.org/docs/8.2/interactive/sql-createtrigger.html) The proposed change is wrong anyway: AFAICS from looking at the code, an RI_ConstraintTrigger_XXXXX name is only generated for triggers that are created in support of FOREIGN KEY constraint syntax. If you use CREATE CONSTRAINT TRIGGER then the trigger name is whatever you say it is. I don't recall if it was always like that, but that's definitely the behavior in CVS HEAD. It would be a mistake to assume that FK constraint triggers are fired in creation order anyway, since the lexical sorting of strings isn't the same as numeric order (not to mention OID wraparound issues). regards, tom lane