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

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: Infinite recursion detected... How do I prevent that?
Дата
Msg-id 20050119143419.GE18648@svana.org
обсуждение исходный текст
Ответ на Infinite recursion detected... How do I prevent that?  (Alban Hertroys <alban@magproductions.nl>)
Список pgsql-general
On Wed, Jan 19, 2005 at 02:57:47PM +0100, Alban Hertroys wrote:
> 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;

<snip>

> 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.

Sorry, RULEs are like macros, they essentially expand and transform
your original query. This also means the expansion does not depend on
the data in your database. So postgresql continaually expands the
query, leading to your infinite recursion error.

Why do you want a RULE anyway, trigger are much easier to understand.
It may be possile to setup some RULEs to avoid recursion but it won't
be easy...

Hope this helps,

--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

Вложения

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

Предыдущее
От: Robby Russell
Дата:
Сообщение: Re: PostgreSQL 8.0.0 Released
Следующее
От: Michael Garriss
Дата:
Сообщение: Need help recovering