Re: How to avoid Trigger ping/pong / infinite loop

From: David Wheeler <hippysoyboy(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: How to avoid Trigger ping/pong / infinite loop
Date: 2023-02-16 19:42:39
Message-ID: 87FC4042-E7F1-4A53-AE60-1C84B5276713@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


>> Are there techniques for situations like this?

Just have two triggers, one for each column, and ensure that if your trigger doesn’t change the value then it doesn’t do an update on the other column. Each time you do update both triggers will run but only one will make a change, so that will break the cycle

For insert case ensure the triggers do nothing if their source col is null

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jonathan S. Katz 2023-02-16 19:43:16 Re: Support logical replication of DDLs
Previous Message Peter Geoghegan 2023-02-16 19:41:53 Re: Automatic aggressive vacuum on almost frozen table takes too long