Re: What Is The Firing Order?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
Cc: cnliou(at)eurosport(dot)com, pgsql-general(at)postgresql(dot)org
Subject: Re: What Is The Firing Order?
Date: 2001-09-07 16:45:56
Message-ID: 27601.999881156@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> writes:
>> If we were to modify the code to make the firing order predictable,
>> I'd want it to be user-controllable. A simple hack that comes to
>> mind is to fire triggers in alphabetical order by name --- then you
>> can easily arrange for custom triggers to fall either before or after
>> system-generated ones. But perhaps someone else has a better idea.

> I think that'd probably work, although I think that you probably
> want to ensure that deferred constraint triggers run after normal
> triggers and immediate constraints when you're running statements
> in their own implicit transactions, since that would model the
> behavior (check on commit) better.

Yes, the semantics of immediate and deferred triggers wouldn't change.
I'm just suggesting that when the system has a choice of legal firing
orders, it adopt an "alphabetical order" rule. AFAICS, all it would
take to implement this is for RelationBuildTriggers to sort the list
of triggers just after it's read them from pg_trigger and before it
inserts them into the TriggerDesc structure (ie, about line 638 of
trigger.c in current sources). The latter insertion is where they
are divided into categories, so the sorting would end up only affecting
the ordering within categories.

The interesting question is not that, really, but whether an
alphabetical-ordering rule will be useful and convenient. I don't
recall exactly how the system chooses names for triggers that it creates
--- if the user can't control those at all then this idea may not be
helpful.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2001-09-07 17:36:37 Re: What Is The Firing Order?
Previous Message Stephan Szabo 2001-09-07 16:33:43 Re: query help