RULE and more than 10 rewrites. - Mailing list pgsql-general

From Vegard Munthe
Subject RULE and more than 10 rewrites.
Date
Msg-id 20030122181010.Q26393-100000@unity.copyleft.no
Whole thread Raw
In response to Re: table schema causes crash  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: RULE and more than 10 rewrites.
List pgsql-general
I have a RULE that does 18 rewrites. This is a RULE that saves me alot of
work when rewriting some software, but the RULE always fails since PGSQL
seems tp think 10 or more rewrites constitutes a loop.

"ERROR:  query rewritten 10 times, may contain cycles"

Is there any way I can set the rewrite limit to more than 10, say 100,
which would be more of a safeguard number for loops?

If not, should I use a trigger on the view the RULE is working on at the
moment?

For those interested my rule looks like this:
---
CREATE RULE person_update AS ON UPDATE TO person_view DO INSTEAD
    (
    UPDATE attribute SET value = new.firstname WHERE
               attrtype = 'firstname' AND objectid = old.id;
    UPDATE attribute SET value = new.middlename WHERE
               attrtype = 'middlename' AND objectid = old.id;
    UPDATE attribute SET value = new.lastname WHERE
               attrtype = 'lastname' AND objectid = old.id;
    UPDATE attribute SET value = new.nickname WHERE
               attrtype = 'nickname' AND objectid = old.id;
    UPDATE attribute SET value = new.membernumber WHERE
               attrtype = 'membernumber' AND objectid = old.id;
    UPDATE attribute SET value = new.streetaddress WHERE
               attrtype = 'streetaddress' AND objectid = old.id;
    UPDATE attribute SET value = new.zipcode WHERE
               attrtype = 'zipcode' AND objectid = old.id;
    UPDATE attribute SET value = new.city WHERE
               attrtype = 'city' AND objectid = old.id;
    UPDATE attribute SET value = new.country WHERE
               attrtype = 'country' AND objectid = old.id;
    UPDATE attribute SET value = new.phone WHERE
               attrtype = 'phone' AND objectid = old.id;
    UPDATE attribute SET value = new.email WHERE
               attrtype = 'e-mail' AND objectid = old.id;
    UPDATE attribute SET value = new.mobilephone WHERE
               attrtype = 'mobilephone' AND objectid = old.id;
    UPDATE attribute SET value = new.dept WHERE
               attrtype = 'dept' AND objectid = old.id;
    UPDATE attribute SET value = new.fromdate WHERE
               attrtype = 'fromdate' AND objectid = old.id;
    UPDATE attribute SET value = new.birthday WHERE
               attrtype = 'birthday' AND objectid = old.id;
    UPDATE attribute SET value = new.username WHERE
               attrtype = 'username' AND objectid = old.id;
    UPDATE attribute SET value = new.password WHERE
               attrtype = 'password' AND objectid = old.id;
    UPDATE attribute SET value = new.language WHERE
               attrtype = 'language' AND objectid = old.id
    );
---

(Pretty ugly huh?)

-- Vegard Munthe


pgsql-general by date:

Previous
From: "David Blood"
Date:
Subject: agregates
Next
From: pginfo
Date:
Subject: vacuum problem