Re: Trigger position - Mailing list pgsql-hackers

From Chapman Flack
Subject Re: Trigger position
Date
Msg-id 614211C4.5060707@anastigmatix.net
Whole thread Raw
In response to Trigger position  (Marcos Pegoraro <marcos@f10.com.br>)
List pgsql-hackers
On 09/15/21 06:28, Marcos Pegoraro wrote:

> Oracle and SQL Server have FOLLOWS and PRECEDES when defining trigger
> execution order. Firebird has POSITION, which I like it more.

Between those two, I think my vote would come down the other way,
assuming FOLLOWS and PRECEDES work the way I am guessing they do:
you would be specifying the firing order between triggers whose
relative order you care about, and leaving it unspecified between
triggers whose relative order doesn't matter.

I find that an appealing general solution that allows the machine
to find a satisfactory order, and is less fussy than trying to manually
create a total order for all of the triggers (even those whose relative
order may not matter) by arbitrarily fussing with names or integers.

It resembles similar constructs in lots of other things, like the way
grammar precedences are specified [0] in SDF.

It may be objected that this makes a trigger order that is less
fully determined in advance, and can lead to issues that are harder
to reason out if you forgot to specify a relative order that matters.

But balancing that is that it may be easier in general to reason about
just the relative orders that matter, undistracted by any that don't.
In some settings, leaving unspecified the ones that don't may increase
opportunities for optimization. (Not that I have any specific optimizations
in mind for this setting.)

One could even think about a test mode that would deliberately randomize
the relative order between triggers where it hasn't been specified.

Regards,
-Chap


[0]
https://www.metaborg.org/en/latest/source/langdev/meta/lang/sdf3/reference.html#priorities



pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Trigger position
Next
From: Marcos Pegoraro
Date:
Subject: Re: Trigger position