Re: How to avoid Trigger ping/pong / infinite loop - Mailing list pgsql-general

From David G. Johnston
Subject Re: How to avoid Trigger ping/pong / infinite loop
Date
Msg-id CAKFQuwZb+jY2A_j2MjJszBmn8YPW1imwnjefGtjR2=1NiNqdAA@mail.gmail.com
Whole thread Raw
In response to How to avoid Trigger ping/pong / infinite loop  (Dominique Devienne <ddevienne@gmail.com>)
Responses Re: How to avoid Trigger ping/pong / infinite loop  (David Wheeler <hippysoyboy@gmail.com>)
List pgsql-general
On Thu, Feb 16, 2023 at 10:43 AM Dominique Devienne <ddevienne@gmail.com> wrote:
Are there techniques for situations like this?

This question is not too far from my earlier question, in the sense that a trigger would need to know the context in which it was triggered, i.e. directly (then update the other model), or indirectly (don't update, the change is boomerang'ing around from our own change).

As with the other question - a trigger does not know how the insert/update/delete action came into existence, it is only reacting to the fact that a given row is being added/updated/removed from its table.  You might be able to expend a non-trivial amount of effort trying to figure out schemes whereby such information can be inferred but you are fighting the system.

PS: At time point, changing the legacy code base is not really an option...

Then maybe you need to design the new system to behave in a manner similar to the legacy system for the stuff they share in common.  You can then have a uni-directional trigger going from legacy to modern.

David J.

pgsql-general by date:

Previous
From: Brad White
Date:
Subject: Re: DELETE trigger, direct or indirect?
Next
From: "David G. Johnston"
Date:
Subject: Re: Vacuum full issue