From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | James Cloos <cloos(at)jhcloos(dot)com> |
Cc: | pgsql-docs(at)postgresql(dot)org |
Subject: | Re: plperl and triggers |
Date: | 2006-09-11 15:44:34 |
Message-ID: | 20060911154434.GA306@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-docs |
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
From | Date | Subject | |
---|---|---|---|
Next Message | James Cloos | 2006-09-14 22:07:24 | Re: plperl and triggers |
Previous Message | James Cloos | 2006-09-11 03:41:38 | plperl and triggers |