X-Original-To: pgsql-docs@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C718B476367 for ; Sun, 13 Apr 2003 23:58:28 -0400 (EDT) Received: from tummy.com (secure.tummy.com [198.49.126.3]) by postgresql.org (Postfix) with ESMTP id 0932447580B for ; Sun, 13 Apr 2003 23:58:28 -0400 (EDT) Received: (qmail 24540 invoked by uid 10); 14 Apr 2003 03:58:56 -0000 Received: (qmail 31631 invoked by uid 500); 14 Apr 2003 03:58:29 -0000 Date: Sun, 13 Apr 2003 21:58:29 -0600 From: Sean Reifschneider To: Tom Lane Cc: pgsql-docs@postgresql.org Subject: Re: Docs patch to note that rules only get run once per query. Message-ID: <20030414035829.GI7507@tummy.com> References: <20030413234349.GF7507@tummy.com> <1569.1050292052@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1569.1050292052@sss.pgh.pa.us> User-Agent: Mutt/1.4.1i X-Spam-Status: No, hits=-34.8 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_MUTT 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/24 X-Sequence-Number: 1750 On Sun, Apr 13, 2003 at 11:47:32PM -0400, Tom Lane wrote: >Sean Reifschneider writes: >> I've made the following patch to the current CVS docs. > >> + Note that rules are only invoked once per query. > ><> This still seems like a serious oversimplification or >misexplanation to me. It's true that a rule creates only one new query >to execute alongside each user-supplied query --- but that additional >query can execute upon many individual rows. So I feel dissatisfied >with the above "clarification". Can you think of another way to explain >it? Unfortunately, I really don't understand it... My first thought was that it was a bug, but when I presented it to the bugs list they said that the rule only gets executed once per query and that triggers should be used if you want to run on every impacted row. Perhaps this re-wording make is more clear? 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. Sean -- *** Quits: TITANIC (Excess Flood) Sean Reifschneider, Inimitably Superfluous tummy.com, ltd. - Linux Consulting since 1995. Qmail, Python, SysAdmin Back off man. I'm a scientist. http://HackingSociety.org/