X-Original-To: pgsql-docs@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 99D9047610C for ; Mon, 14 Apr 2003 12:36:30 -0400 (EDT) Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by postgresql.org (Postfix) with SMTP id 6F43B475CE5 for ; Mon, 14 Apr 2003 12:36:27 -0400 (EDT) Received: (qmail 26313 invoked by uid 65534); 14 Apr 2003 16:37:02 -0000 Received: from p3E9E70F6.dip0.t-ipconnect.de (EHLO p3E9E70F6.dip0.t-ipconnect.de) (62.158.112.246) by mail.gmx.net (mp021-rz3) with SMTP; 14 Apr 2003 18:37:02 +0200 Date: Mon, 14 Apr 2003 18:38:16 +0200 (CEST) From: Peter Eisentraut X-X-Sender: peter@peter.localdomain To: Sean Reifschneider Cc: Tom Lane , Subject: Re: Docs patch to note that rules only get run once per query. In-Reply-To: <20030414035829.GI7507@tummy.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-31.7 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES,USER_AGENT_PINE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/28 X-Sequence-Number: 1754 Sean Reifschneider writes: > > > Note that rules are only invoked once per query. This may be a problem > in instances where the rule is updating table A based on table B's > contents. If you do a multi-row delete on B, the rule may get run > only after the delete of the first row, not after all deletes finish. > In this case, you will have to use a trigger. > > This can't possibly be true. Rules are never invoked "after" any deletion of any row. Take a close look at the examples of update rules in the documentation. Read how the references to NEW and OLD are resolved. Play out the expansion of your example of paper. The rule will expand your initial command to a big and ugly set of commands. But all those commands are applied like any normal command that you could have entered by hand. So if too few or too many rows are affected, that's because of the conditions attached to the command. -- Peter Eisentraut peter_e@gmx.net