Re: rule creating infinite recursion not sure why

From: Andreas Kretschmer <akretschmer(at)spamfence(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: rule creating infinite recursion not sure why
Date: 2007-02-16 15:22:52
Message-ID: 20070216152252.GA19276@KanotixBox
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Gene <genekhart(at)gmail(dot)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°

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adam Rich 2007-02-16 15:23:44 Re: Problem writing sql statement....
Previous Message Tom Lane 2007-02-16 15:22:20 Re: rule creating infinite recursion not sure why