Re: Trigger position

2021-09-15 Thread Marcos Pegoraro
We can run triggers using position only, this way we don´t have these few cycles to determine ordering. On creation time we populate position, even if it's not set, so for the first time position will match trigger names. When user changes a trigger position we sum 1 to the followers. re

Re: Trigger position

2021-09-15 Thread Chapman Flack
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 guess

Re: Trigger position

2021-09-15 Thread Alvaro Herrera
On 2021-Sep-15, Pavel Stehule wrote: > Triggers that depend on execution order are pretty hell. It is a clean > signal of some crazy design and overusing of triggers. Yeah. The only case I've seen where order of triggers was important (beyond the "before" / "after" classification) is where you h

Re: Trigger position

2021-09-15 Thread Pavel Stehule
st 15. 9. 2021 v 17:14 odesílatel Euler Taveira napsal: > On Wed, Sep 15, 2021, at 10:51 AM, Alvaro Herrera wrote: > > In a computer system, alphabet letters are just a different way to > present numbers, so you just choose ASCII letters that match what you > want. You can use "AA_first_trigger"

Re: Trigger position

2021-09-15 Thread Euler Taveira
On Wed, Sep 15, 2021, at 10:51 AM, Alvaro Herrera wrote: > In a computer system, alphabet letters are just a different way to > present numbers, so you just choose ASCII letters that match what you > want. You can use "AA_first_trigger", "BB_second_trigger", > "AB_nope_this_is_second" and you'll b

Re: Trigger position

2021-09-15 Thread Marcos Pegoraro
When I was writing my initial email I was remembering exactly this, my first basic programs. I would like this feature more because I sometimes have a mess of triggers when this trigger function is fired on several tables and it needs to be the first on this table but not on that table. And usually

Re: Trigger position

2021-09-15 Thread Alvaro Herrera
On 2021-Sep-15, Marcos Pegoraro wrote: > This problem can raise ... there is a trigger foo using position 1, please > choose another This is reminiscent of the old BASIC programming language, where you eventually learn to choose line numbers that aren't consecutive, so that if you later have to a

Re: Trigger position

2021-09-15 Thread Marcos Pegoraro
Correct, we need a field tgposition on pg_trigger and when it´s null we follow normal ordering select * from pg_trigger where tgrelid = X and tgtype = Y order by tgposition nulls last, tgname regards, Marcos Em qua., 15 de set. de 2021 às 09:35, Andreas Karlsson escreveu: > On 9/15/21 1:40 PM,

Re: Trigger position

2021-09-15 Thread Andreas Karlsson
On 9/15/21 1:40 PM, Tom Lane wrote: Marcos Pegoraro writes: Alphabetical order of triggers sometimes makes me write a_Recalc or z_Calc to be sure it´ll be the first or the last trigger with same event of that table Oracle and SQL Server have FOLLOWS and PRECEDES when defining trigger executi

Re: Trigger position

2021-09-15 Thread Marcos Pegoraro
This way would be interesting for those are migrating from these databases too. But ok, I´ll forget it. Em qua., 15 de set. de 2021 às 08:40, Tom Lane escreveu: > Marcos Pegoraro writes: > > Alphabetical order of triggers sometimes makes me write a_Recalc or > z_Calc > > to be sure it´ll be the

Re: Trigger position

2021-09-15 Thread Marcos Pegoraro
This problem can raise ... there is a trigger foo using position 1, please choose another Atenciosamente, Em qua., 15 de set. de 2021 às 07:59, Daniel Gustafsson escreveu: > > On 15 Sep 2021, at 12:28, Marcos Pegoraro wrote: > > > CREATE TRIGGER RECALC_THAT BEFORE UPDATE POSITION 1 ON ORDER

Re: Trigger position

2021-09-15 Thread Tom Lane
Marcos Pegoraro writes: > Alphabetical order of triggers sometimes makes me write a_Recalc or z_Calc > to be sure it´ll be the first or the last trigger with same event of that > table > Oracle and SQL Server have FOLLOWS and PRECEDES when defining trigger > execution order. Firebird has POSITION

Re: Trigger position

2021-09-15 Thread Daniel Gustafsson
> On 15 Sep 2021, at 12:28, Marcos Pegoraro wrote: > CREATE TRIGGER RECALC_THAT BEFORE UPDATE POSITION 1 ON ORDERS... > CREATE TRIGGER DO_OTHER_CALC BEFORE UPDATE POSITION 2 ON ORDERS... For those not familiar with Firebird: triggers are executing in alphabetical order within a position number,

Trigger position

2021-09-15 Thread Marcos Pegoraro
Hi Hackers, Alphabetical order of triggers sometimes makes me write a_Recalc or z_Calc to be sure it´ll be the first or the last trigger with same event of that table Oracle and SQL Server have FOLLOWS and PRECEDES when defining trigger execution order. Firebird has POSITION, which I like it more