Why do I get a circular query when I insert tuples with this rule ? - Mailing list pgsql-general

From xavier.goddeeris@dds.delphiauto.com (Xavier Goddeeris)
Subject Why do I get a circular query when I insert tuples with this rule ?
Date
Msg-id 6bf22014.0110150530.389addfd@posting.google.com
Whole thread Raw
Responses Re: Why do I get a circular query when I insert tuples with this rule ?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Hi. Here is my problem:

I am using PostgreSQL 7.1.3. I want to create a RULE to modify the
values in an insert query. Here is my rule:

CREATE RULE old_error_codes AS ON insert to Passage
WHERE erreur<>0 and ligne<>1 and erreur<500 DO INSTEAD
insert into Passage(idinjecteur, ligne, datedesortie, estbon,
nomcible, erreur, derniertest, nodupassage)
values (new.idinjecteur, new.ligne, new.datedesortie, new.estbon,
new.nomcible, new.erreur+500, new.derniertest, new.nodupassage);

What I don't understand, is that, with this rule when I insert a tuple
I get the error message "ERROR: Query rewritten 10 times, may contain
cycles".

Once he has done for the first time, the action specified in the rule,
Postgres doesn't have to re-execute the action in the rule, because
the second time he checks the rule he finds that "erreur" is not < 500
(the condition of the rule is false).

Don't understand. Please help me.

Thank you,
xav.

pgsql-general by date:

Previous
From: Debian GNU/Linux User :-D
Date:
Subject: Re: WWW interface for postgres
Next
From: roypgsqlgen@xemaps.com
Date:
Subject: