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

Поиск
Список
Период
Сортировка
От Roman Neuhauser
Тема Re: Infinite recursion detected... How do I prevent that?
Дата
Msg-id 20050119153048.GB74874@isis.wad.cz
обсуждение исходный текст
Ответ на Infinite recursion detected... How do I prevent that?  (Alban Hertroys <alban@magproductions.nl>)
Список 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 по дате отправления:

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: Unique Index
Следующее
От: "Nefnifi, Kasem"
Дата:
Сообщение: stored procedure from oracle to pgsql