Why do I get a circular query when I insert tuples with this rule ?

From: xavier(dot)goddeeris(at)dds(dot)delphiauto(dot)com (Xavier Goddeeris)
To: pgsql-general(at)postgresql(dot)org
Subject: Why do I get a circular query when I insert tuples with this rule ?
Date: 2001-10-15 13:30:07
Message-ID: 6bf22014.0110150530.389addfd@posting.google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Brent R. Matzelle 2001-10-15 13:35:32 Re: Problem in installing Postgresql-7.1.2
Previous Message John P. Looney 2001-10-15 13:23:12 writing & flushing C extensions