Received: from mail48.fg.online.no (mail48-s.fg.online.no [148.122.161.48]) by postgresql.org (Postfix) with ESMTP id 15CB1476A07 for ; Tue, 9 Jul 2002 09:41:51 -0400 (EDT) Received: from epostleser.online.no (epostleser12.frisurf.no [148.122.3.20]) by mail48.fg.online.no (8.9.3/8.9.3) with ESMTP id PAA21921; Tue, 9 Jul 2002 15:41:43 +0200 (MET DST) X-WebMail-UserID: kreide@online.no Date: Tue, 9 Jul 2002 15:41:43 +0200 From: Kristian Eide To: Tom Lane Cc: pgsql-sql X-EXP32-SerialNo: 50000140 Subject: Re: Rule WHERE condition problem Message-ID: <3D2C1A19@epostleser.online.no> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Mailer: InterChange (Hydra) SMTP v3.62 X-Archive-Number: 200207/111 X-Sequence-Number: 8490 >> ERROR: query rewritten 10 times, may contain cycles >> It would seem that my WHERE clause is not checked before the action is run. >No, the WHERE clause is essentially transformed into part of the rule >query. You can't ever write a rule of the form > ON UPDATE TO b DO UPDATE b ... >because it *will* be an infinite loop, condition or no condition. OK, perhaps the documentation should state that recursive rules are not supported. >Consider using a trigger instead. Yes, I have written a PL/pgsql function and a trigger for this, which seems to work perfectly. A rule would have been much simpler though :) Thanks. --- Kristian