Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 96AC62E2DF9 for ; Wed, 16 Jan 2008 05:21:46 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 65144-09 for ; Wed, 16 Jan 2008 05:21:38 -0400 (AST) Received: from ptb-relay01.plus.net (ptb-relay01.plus.net [212.159.14.212]) by postgresql.org (Postfix) with ESMTP id CE6BE2E2DF7 for ; Wed, 16 Jan 2008 05:21:40 -0400 (AST) Received: from [84.51.143.99] (helo=server3.office.archonet.com) by ptb-relay01.plus.net with esmtp (Exim) id 1JF4Sn-0002WL-Ll; Wed, 16 Jan 2008 09:21:37 +0000 Received: from [192.168.1.36] (dell36.office.archonet.com [192.168.1.36]) by server3.office.archonet.com (Postfix) with ESMTP id 36A2C274060; Wed, 16 Jan 2008 09:21:37 +0000 (GMT) Message-ID: <478DCCA1.4060505@archonet.com> Date: Wed, 16 Jan 2008 09:21:37 +0000 From: Richard Huxton User-Agent: Thunderbird 2.0.0.9 (X11/20071031) MIME-Version: 1.0 To: Gerardo Herzig CC: "pgsql-sql@postgresql.org" Subject: Re: obtaining the query string inside a trigger References: <478D25B7.8030308@fmed.uba.ar> In-Reply-To: <478D25B7.8030308@fmed.uba.ar> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200801/138 X-Sequence-Number: 29991 Gerardo Herzig wrote: > Hi all. Im working on a "on each statement" update trigger, so NEW and > OLD are NULL. > Suppose a simple query like 'update mytable set id=id+500 where id < > 50'...There is a way to obtaining the 'set id=..' and the where clause > in some way? Afraid not. It might be possible to implement in the simple case, but what with views rewriting queries and triggers issuing their own secondary queries it's not always obvious what "the" query would be. What we really need is NEW and OLD as sets of affected rows in statement-queries. Unfortunately that's not implemented yet either - it's on the TODO I believe though. -- Richard Huxton Archonet Ltd