Re: Infinite recursion detected... How do I prevent that? - Mailing list pgsql-general

From Roman Neuhauser
Subject Re: Infinite recursion detected... How do I prevent that?
Date
Msg-id 20050119153048.GB74874@isis.wad.cz
Whole thread Raw
In response to Infinite recursion detected... How do I prevent that?  (Alban Hertroys <alban@magproductions.nl>)
List pgsql-general
# alban@magproductions.nl / 2005-01-19 14:57:47 +0100:
> I have a rule similar to this:
>
> CREATE RULE rule_branch_delete AS
> ON DELETE TO tree
> DO DELETE
>      FROM tree
>     WHERE ancestor_id IS NOT NULL
>       AND OLD.child_id = ancestor_id;

> If I try a delete on the tree table I get "Infinite recursion detected
> on rules on tree". I'm pretty sure it's not "infinite" in my case, how
> can I make it delete the records regardless this "infinity"?

    cover the table with a view, as in:

    CREATE TABLE _tree (
      ancestor_id int,
      child_id int
    );

    CREATE VIEW tree AS
      SELECT * FROM _tree;

    CREATE RULE rule_branch_delete AS
    ON DELETE TO tree
    DO INSTEAD (
      DELETE FROM _tree ...; (the original DELETE redirected to _tree)
      DELETE FROM _tree
        WHERE ancestor_id IS NOT NULL
          AND OLD.child_id = ancestor_id;
    );


--
If you cc me or remove the list(s) completely I'll most likely ignore
your message.    see http://www.eyrie.org./~eagle/faqs/questions.html

pgsql-general by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: Unique Index
Next
From: "Nefnifi, Kasem"
Date:
Subject: stored procedure from oracle to pgsql