X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 607049DC87B for ; Fri, 24 Feb 2006 13:37:57 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 56974-07 for ; Fri, 24 Feb 2006 13:37:56 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 0DFE19DC80C for ; Fri, 24 Feb 2006 13:37:54 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id k1OHbpW5004348; Fri, 24 Feb 2006 12:37:51 -0500 (EST) To: Alvaro Herrera cc: Achilleus Mantzios , pgsql-sql@postgresql.org Subject: Re: After Trigger assignment to NEW In-reply-to: <20060224171652.GD7696@surnet.cl> References: <3649.1140797162@sss.pgh.pa.us> <20060224171652.GD7696@surnet.cl> Comments: In-reply-to Alvaro Herrera message dated "Fri, 24 Feb 2006 14:16:52 -0300" Date: Fri, 24 Feb 2006 12:37:51 -0500 Message-ID: <4347.1140802671@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.111 required=5 tests=[AWL=0.111] X-Spam-Score: 0.111 X-Spam-Level: X-Archive-Number: 200602/298 X-Sequence-Number: 24308 Alvaro Herrera writes: > Tom Lane wrote: >> Achilleus Mantzios writes: >>> Is there a reason that the NEW values should remain unchanged in AFTER >>> row triggers? >> >> By definition, an AFTER trigger is too late to change what was stored. >> Use a BEFORE trigger. > But a BEFORE trigger would alter the stored tuple, which is not what > Achilleus wants AFAIU. Oh, I misunderstood what he wanted ... and now that I do understand, I think it's a really terrible idea :-(. A large part of the point of using an AFTER trigger is to be certain you know exactly what got stored. (BEFORE triggers can never know this with certainty because there might be another BEFORE trigger that runs after them and edits the tuple some more.) If one AFTER trigger could falsify the data seen by the next, then that guarantee crumbles. For instance, a minor programming error in a user-written trigger could break foreign-key checking. No thanks. > I think the desired effect can be had by having DBMirror check the > source relation of the inserted tuple (There is a hidden attributa > called tableoid IIRC that can be used for that, I think). I agree --- the correct solution is to change the DBMirror triggers to incorporate the desired filtering logic. regards, tom lane