Re: BUG #1391: Perl trusted language triggers can't properly access $_SHARED

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Sokolov Yura" <falcon(at)intercable(dot)ru>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #1391: Perl trusted language triggers can't properly access $_SHARED
Date: 2005-01-14 16:27:28
Message-ID: 24097.1105720048@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Sokolov Yura" <falcon(at)intercable(dot)ru> writes:
> I created triggers In Perl trusted (ActivePerl 5.8.4 build 810) and it
> crashes when triggers FOR EACH STATEMENT tried to access $_SHARED when
> triggers FOR EACH ROW not accessed it before

Actually _SHARED had nothing to do with it: the trigger handler was
trying to fetch new/old tuples even though FOR EACH STATEMENT.
I've applied the attached patch. Thanks for the report!

regards, tom lane

*** src/pl/plperl/plperl.c.orig Tue Jan 11 10:35:22 2005
--- src/pl/plperl/plperl.c Fri Jan 14 11:19:23 2005
***************
*** 338,372 ****
if (TRIGGER_FIRED_BY_INSERT(tdata->tg_event))
{
event = "INSERT";
! hv_store(hv, "new", 3,
! plperl_hash_from_tuple(tdata->tg_trigtuple, tupdesc),
! 0);
}
else if (TRIGGER_FIRED_BY_DELETE(tdata->tg_event))
{
event = "DELETE";
! hv_store(hv, "old", 3,
! plperl_hash_from_tuple(tdata->tg_trigtuple, tupdesc),
! 0);
}
else if (TRIGGER_FIRED_BY_UPDATE(tdata->tg_event))
{
event = "UPDATE";
! hv_store(hv, "old", 3,
! plperl_hash_from_tuple(tdata->tg_trigtuple, tupdesc),
! 0);
! hv_store(hv, "new", 3,
! plperl_hash_from_tuple(tdata->tg_newtuple, tupdesc),
! 0);
}
! else {
event = "UNKNOWN";
- }

hv_store(hv, "event", 5, newSVpv(event, 0), 0);
hv_store(hv, "argc", 4, newSViv(tdata->tg_trigger->tgnargs), 0);

! if (tdata->tg_trigger->tgnargs != 0)
{
AV *av = newAV();
for (i=0; i < tdata->tg_trigger->tgnargs; i++)
--- 338,376 ----
if (TRIGGER_FIRED_BY_INSERT(tdata->tg_event))
{
event = "INSERT";
! if (TRIGGER_FIRED_FOR_ROW(tdata->tg_event))
! hv_store(hv, "new", 3,
! plperl_hash_from_tuple(tdata->tg_trigtuple, tupdesc),
! 0);
}
else if (TRIGGER_FIRED_BY_DELETE(tdata->tg_event))
{
event = "DELETE";
! if (TRIGGER_FIRED_FOR_ROW(tdata->tg_event))
! hv_store(hv, "old", 3,
! plperl_hash_from_tuple(tdata->tg_trigtuple, tupdesc),
! 0);
}
else if (TRIGGER_FIRED_BY_UPDATE(tdata->tg_event))
{
event = "UPDATE";
! if (TRIGGER_FIRED_FOR_ROW(tdata->tg_event))
! {
! hv_store(hv, "old", 3,
! plperl_hash_from_tuple(tdata->tg_trigtuple, tupdesc),
! 0);
! hv_store(hv, "new", 3,
! plperl_hash_from_tuple(tdata->tg_newtuple, tupdesc),
! 0);
! }
}
! else
event = "UNKNOWN";

hv_store(hv, "event", 5, newSVpv(event, 0), 0);
hv_store(hv, "argc", 4, newSViv(tdata->tg_trigger->tgnargs), 0);

! if (tdata->tg_trigger->tgnargs > 0)
{
AV *av = newAV();
for (i=0; i < tdata->tg_trigger->tgnargs; i++)

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruno Wolff III 2005-01-14 16:31:57 Re: BUG #1388: documentation/announcement suggestion
Previous Message Yves.Carlier 2005-01-14 16:26:50 success in compiler Postgres 8.0.0rc5 on Red Hat ES3.0 (update 4) on Intel EM64T