From: | Roman Neuhauser <neuhauser(at)chello(dot)cz> |
---|---|
To: | Alban Hertroys <alban(at)magproductions(dot)nl> |
Cc: | Postgres general mailing list <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Infinite recursion detected... How do I prevent that? |
Date: | 2005-01-19 15:30:48 |
Message-ID: | 20050119153048.GB74874@isis.wad.cz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
# alban(at)magproductions(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Együd Csaba (Freemail) | 2005-01-19 15:43:00 | Re: PostgreSQL 8.0.0 Released |
Previous Message | Stephan Szabo | 2005-01-19 15:19:59 | Re: Unique Index |