From: | Alban Hertroys <alban(at)magproductions(dot)nl> |
---|---|
To: | Postgres general mailing list <pgsql-general(at)postgresql(dot)org> |
Subject: | Infinite recursion detected... How do I prevent that? |
Date: | 2005-01-19 13:57:47 |
Message-ID: | 41EE675B.6070005@magproductions.nl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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;
The data is oraganized like this:
ancestor_id child_id
================================
NULL 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
2 4
2 5
2 6
3 7
3 8
etc.
This is an optimization table that relates all nodes in a branch to all
it's ancestor nodes; to it's parent, to it's grand parent to it's grand
grand parent, etc.
The tree is 3 to 5 levels deep. The intention is to delete all children
of a branch that share the same ancestor when an ancestor gets deleted.
This happens recursively, of course.
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"?
At the moment I use a trigger, but I would prefer a rule.
Alban.
From | Date | Subject | |
---|---|---|---|
Next Message | Lonni J Friedman | 2005-01-19 14:10:16 | Re: what happened to the website? |
Previous Message | Clive Page | 2005-01-19 13:50:00 | Re: Postgres crashed when adding a sequence column |