X-Original-To: pgsql-docs-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 36AD09FA506 for ; Mon, 11 Sep 2006 01:44:23 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 00882-08 for ; Mon, 11 Sep 2006 04:44:14 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from ore.jhcloos.com (ore.jhcloos.com [64.240.156.239]) by postgresql.org (Postfix) with ESMTP id C8F509FB21B for ; Mon, 11 Sep 2006 01:44:14 -0300 (ADT) Received: from lugabout.jhcloos.org (ppp38.tc-1.buf-ch.ny.localnet.com [69.48.13.38]) (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) (Client CN "lugabout.jhcloos.org", Issuer "ca.jhcloos.com" (verified OK)) by ore.jhcloos.com (Postfix) with ESMTP id D764F1C57D for ; Sun, 10 Sep 2006 23:43:53 -0500 (CDT) Received: by lugabout.jhcloos.org (Postfix, from userid 500) id F2CF0214747; Mon, 11 Sep 2006 03:42:01 +0000 (GMT) From: James Cloos To: pgsql-docs@postgresql.org Subject: plperl and triggers Copyright: Copyright 2006 James Cloos X-Hashcash: 1:23:060911:pgsql-docs@postgresql.org::IqVmvKG5ytMyeyAa:0000000000000000000000000000000000006RF4 Date: Sun, 10 Sep 2006 23:41:38 -0400 Message-ID: Lines: 30 User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/23.0.0 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.134 tagged_above=0 required=5 tests=FORGED_RCVD_HELO, SPF_PASS X-Spam-Level: X-Archive-Number: 200609/7 X-Sequence-Number: 3694 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}. 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? Whatever the reality, the doc should be fixed to explain exactly when {old} and {new} exist and their semantics. Liberal use of, eg, elog(WARNING, Dumper(\$_TD)) made it easy to get my trigger function working as desired, but it would be cool to document the details.... (In general, the docs are great. I do sometimes have to read a given section more than once -- or thrice -- to get it, but that is as much due to fatigue as anything. And I am one of those who tend to learn new stuff better when reading from paper than from emitive displays like lcds or crts, for whatever reason.) (Or maybe I'm just getting old. ;-) -JimC -- James Cloos OpenPGP: 0xED7DAEA6