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

From Tom Lane
Subject Re: rule creating infinite recursion not sure why
Date
Msg-id 27544.1171639340@sss.pgh.pa.us
Whole thread Raw
In response to rule creating infinite recursion not sure why  (Gene <genekhart@gmail.com>)
List pgsql-general
Gene <genekhart@gmail.com> writes:
> I'm not sure why it's detecting recursion in this case when the rule
> conditional should be false

Rules are macros, which means that expansion has to terminate
statically, not dynamically.  For the particular purpose you seem to
have here, it'd be a lot more manageable and a lot more efficient
to use a BEFORE UPDATE trigger instead of a rule.

    if new.pattern <> old.pattern then
        new.flag = false;
    end if;
    return new;

Or are you trying to change some other row than the one being updated?

            regards, tom lane

pgsql-general by date:

Previous
From: "Adam Rich"
Date:
Subject: Re: Problem writing sql statement....
Next
From: Andreas Kretschmer
Date:
Subject: Re: rule creating infinite recursion not sure why