Re: rule creating infinite recursion not sure why - Mailing list pgsql-general

From Andreas Kretschmer
Subject Re: rule creating infinite recursion not sure why
Date
Msg-id 20070216152252.GA19276@KanotixBox
Whole thread Raw
In response to rule creating infinite recursion not sure why  (Gene <genekhart@gmail.com>)
List pgsql-general
Gene <genekhart@gmail.com> schrieb:

> I was trying to create a rule to set a column to false whenever another column
> was changed:
>
> CREATE RULE...
> ON UPDATE TO criterion
>    WHERE new.pattern::text <> old.pattern::text DO UPDATE table SET flag =
> false
>   WHERE id = _o_l_d_._i_d
>
> pattern | id
> 12345  | 1
>
> => update criterion set pattern = '12345' where id = 1;
> ERROR:  infinite recursion detected in rules for relation "criterion"

I think, you should better use a TRIGGER and modify the NEW.flag within
the Trigger. Your solution creates a new UPDATE when an UPDATE occur.


Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect.                              (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly."    (unknow)
Kaufbach, Saxony, Germany, Europe.              N 51.05082°, E 13.56889°

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: rule creating infinite recursion not sure why
Next
From: Alvaro Herrera
Date:
Subject: Re: rule creating infinite recursion not sure why