Infinite recursion detected... How do I prevent that?

Поиск
Список
Период
Сортировка
От Alban Hertroys
Тема Infinite recursion detected... How do I prevent that?
Дата
Msg-id 41EE675B.6070005@magproductions.nl
обсуждение исходный текст
Ответы Re: Infinite recursion detected... How do I prevent that?
Re: Infinite recursion detected... How do I prevent that?
Список 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.

В списке pgsql-general по дате отправления:

Предыдущее
От: Clive Page
Дата:
Сообщение: Re: Postgres crashed when adding a sequence column
Следующее
От: "Esteban Kemp"
Дата:
Сообщение: Best Linux Distribution