X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E41D647580B for ; Sat, 26 Apr 2003 04:50:13 -0400 (EDT) Received: from smtp.web.de (smtp01.web.de [217.72.192.180]) by postgresql.org (Postfix) with ESMTP id D5498474E42 for ; Sat, 26 Apr 2003 04:50:09 -0400 (EDT) Received: from p5081810f.dip0.t-ipconnect.de ([80.129.129.15] helo=web.de) by smtp.web.de with asmtp (TLSv1:RC4-MD5:128) (WEB.DE(Exim) 4.97 #53) id 199LNn-0000QB-00; Sat, 26 Apr 2003 10:50:07 +0200 Message-ID: <3EAA483E.2060204@web.de> Date: Sat, 26 Apr 2003 10:50:06 +0200 From: Andreas Pflug User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030312 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Josh Berkus , pgsql-sql@postgresql.org Subject: Re: Statement triggers 7.4 NEW/OLD References: <3EA7CD6A.9080404@web.de> <3EA9EFA3.EF4C0D1@Yahoo.com> <200304252120.01644.josh@agliodbs.com> In-Reply-To: <200304252120.01644.josh@agliodbs.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-34.4 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,RCVD_IN_NJABL, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MOZILLA_UA 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/394 X-Sequence-Number: 13095 Josh Berkus wrote: >>IMHO statement triggers instead should have access to the NEW and OLD >>rows through some mechanism. I can think of NEW and OLD being reference >>cursors in the case of statement triggers, and the trigger then can >>FETCH the rows from there. >> >> > >Yeah; how else could it possibly work? > > > Why do it easy if you can have it difficult? ;-) If I want to perform row by row actions I use a row level trigger! Statement triggers need to work like this: Instead of NEW.foo := 1; you code UPDATE NEW SET foo=1; If the statement trigger doesn't offer a complete SETOF RECORD, It's pretty useless. In my case, updates and deletes on a table could possibly touch thousands of rows at the same time, and the trigger will update aggregated values in another table, and insert or delete a third one with 3-4 additional statements. This is pretty fast if implemented as true statement trigger, but will possibly blow the system if done row by row. Imagine a single statement, that triggers ROW_COUNT*4 statements, where ROW_COUNT can easily be 1000, 10000 or much more! Regards, Andreas