plperl and triggers

From: James Cloos <cloos(at)jhcloos(dot)com>
To: pgsql-docs(at)postgresql(dot)org
Subject: plperl and triggers
Date: 2006-09-11 03:41:38
Message-ID: m3slizm5me.fsf@lugabout.jhcloos.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

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 <cloos(at)jhcloos(dot)com> OpenPGP: 0xED7DAEA6

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Michael Fuhr 2006-09-11 15:44:34 Re: plperl and triggers
Previous Message Bruce Momjian 2006-09-07 00:06:08 Re: New XML section for documentation