avoiding endless loop in an UPDATE trigger

From: "Norman J(dot) Clarke" <norman(at)combimatrix(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: avoiding endless loop in an UPDATE trigger
Date: 2001-02-26 19:53:51
Message-ID: Pine.LNX.4.21.0102261151060.28752-100000@curly.combimatrix.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

I am attempting to write a trigger function or rule in pl/pgsql that runs
on UPDATE to a table named "nodes". From inside this trigger, I would like
to UPDATE the same "nodes" table. How can I do this without entering into
an endless loop?

At the moment, I have a trigger which does the following:

<snip>
UPDATE pg_class SET reltriggers = 0 WHERE relname = ''nodes'';
</snip>

At the end of the function, I again update pg_class.reltriggers to its
previous value, thus reenabling triggers.

The problem with this is that it disables all of my FOREIGN KEY
constraints during function execution, which is undesirable.

I am sure there must be a more elegant way to accomplish this, but I have
not found it. Could anyone offer some advice?

Thanks!

Regards,

Norm

--------------------------------------
Norman Clarke
Combimatrix Corp Software Development
Harbour Pointe Tech Center
6500 Harbour Heights Pkwy, Suite 301
Mukilteo, WA 98275

tel: 425.493.2240
fax: 425.493.2010
--------------------------------------

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dominic J. Eidson 2001-02-26 20:29:22 Re: avoiding endless loop in an UPDATE trigger
Previous Message Aristide Aragon 2001-02-26 18:51:11 Re: Help with pq++