avoiding endless loop in an UPDATE trigger - Mailing list pgsql-general

From Norman J. Clarke
Subject avoiding endless loop in an UPDATE trigger
Date
Msg-id Pine.LNX.4.21.0102261151060.28752-100000@curly.combimatrix.com
Whole thread Raw
Responses Re: avoiding endless loop in an UPDATE trigger
Re: avoiding endless loop in an UPDATE trigger
List 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
--------------------------------------



pgsql-general by date:

Previous
From: Aristide Aragon
Date:
Subject: Re: Help with pq++
Next
From: "Dominic J. Eidson"
Date:
Subject: Re: avoiding endless loop in an UPDATE trigger