X-Original-To: pgsql-docs-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id E07F49FB39A for ; Mon, 11 Sep 2006 12:45:05 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 91187-08 for ; Mon, 11 Sep 2006 12:44:54 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by postgresql.org (Postfix) with ESMTP id 8AD3D9FB318 for ; Mon, 11 Sep 2006 12:44:54 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.8/8.13.8) with ESMTP id k8BFiZXt060670 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 11 Sep 2006 09:44:37 -0600 (MDT) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.8/8.13.8) with ESMTP id k8BFiYgE000490; Mon, 11 Sep 2006 09:44:34 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.8/8.13.8/Submit) id k8BFiYW0000489; Mon, 11 Sep 2006 09:44:34 -0600 (MDT) (envelope-from mfuhr) Date: Mon, 11 Sep 2006 09:44:34 -0600 From: Michael Fuhr To: James Cloos Cc: pgsql-docs@postgresql.org Subject: Re: plperl and triggers Message-ID: <20060911154434.GA306@winnie.fuhr.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.169 tagged_above=0 required=5 tests=AWL, SPF_PASS X-Spam-Level: X-Archive-Number: 200609/8 X-Sequence-Number: 3695 On Sun, Sep 10, 2006 at 11:41:38PM -0400, James Cloos wrote: > The manual says that $_TD->{old} contains the old value of the row > being operated on in a trigger, and $_TD->{new} the new value to be > used istead. > > When using plpgsql I find that the equivs OLD and NEW do work that > way, but with plperlu there was only $_TD->{new}. Are you sure the tests were identical other than the trigger function language? Based on your description I'd guess that you did an UPDATE with PL/pgSQL and an INSERT with PL/PerlU. > Perhaps {old} is only set on an update. Or on an AFTER trigger to > an insert? > > Or perhaps {old} only gets set if {new} is altered? New and/or old rows are available in row-level BEFORE and AFTER triggers. New rows are available in INSERT and UPDATE triggers; old rows are available in UPDATE and DELETE triggers. This behavior should be the same in all languages; if you have an example that shows otherwise then please post it. > Whatever the reality, the doc should be fixed to explain exactly > when {old} and {new} exist and their semantics. "A patch would be welcome" :-) The PL/Perl documentation doesn't describe the semantics but the "Triggers" chapter does. If you've found a discrepancy between documentation and behavior then please post a self-contained test case. -- Michael Fuhr