Cascading Trigger Prevention

From: JonXP <JonEckspee(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Cascading Trigger Prevention
Date: 2007-11-28 22:00:58
Message-ID: 05d292fb-bbfa-4737-8280-37e883e43c92@a35g2000prf.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello All,

I have a table that contains a nested set (using paths), and I'm
trying to create a trigger that updates the timestamps of a node and
all of its parents on a modification. Unfortunately, this is causing
infinitely recurring triggers.

The insert occurs, which fires the trigger, which then updates all of
the parent rows, which then fires the trigger again for each update,
which recurses yet again.

I have been looking with no success for a way to turn off triggers,
and am surprised that there is no method of preventing a trigger from
running when performing a query. Even more bothersome is the fact
that a trigger has no way of knowing when it has been called by
another trigger.

I don't want to have to move my modified timestamps to a separate
table just so that the triggers don't recurse themselves, but this is
looking like it will be the case.

Does anyone have any thoughts or alternate suggestions?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Dunstan 2007-11-28 22:13:08 Re: [HACKERS] plperl and regexps with accented characters - incompatible?
Previous Message Richard Huxton 2007-11-28 20:09:02 Re: [Re] Re: [Re] Re: [Re] Re: Unknown winsock error 10061while dumping a big database