public inbox for [email protected]
help / color / mirror / Atom feedFrom: David Pufer <[email protected]>
To: [email protected]
Subject: Re: Improving CREATE CONSTRAINT TRIGGER documentation - trigger firing order
Date: Sat, 21 Apr 2007 18:48:34 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
<[email protected]>
<[email protected]>
Tom Lane wrote:
> Michael Glaesemann <[email protected]> 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
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
>
I tested in in 8.2.3 stable.
e.g. command
CREATE CONSTRAINT TRIGGER my_constraint_trigger_name
AFTER INSERT OR UPDATE OR DELETE
ON my_test_table
DEFERRABLE INITIALLY DEFERRED
FOR EACH ROW EXECUTE PROCEDURE my_test_procedure()
created a row with tgname "RI_ConstraintTrigger_28329" and tgconstrname
"my_constraint_trigger_name" in system catalog in table pg_trigger,
while creation of normal trigger (not constraint trigger) puts its name
into tgname column. As Tom notedm a while ago it might be different in
CVS HEAD and consequently in 8.3.
Thanks for helpful info
David Pufer
view thread (6+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: Improving CREATE CONSTRAINT TRIGGER documentation - trigger firing order
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox