Commit ce6e2fad authored by Tom Lane's avatar Tom Lane

plperl trigger handler tried to fetch new/old tuples even when fired

as a statement trigger :-(.  Per report from Sokolov Yura.
parent 75112d4b
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
* ENHANCEMENTS, OR MODIFICATIONS. * ENHANCEMENTS, OR MODIFICATIONS.
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.66 2005/01/11 06:08:45 tgl Exp $ * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.67 2005/01/14 16:25:42 tgl Exp $
* *
**********************************************************************/ **********************************************************************/
...@@ -338,6 +338,7 @@ plperl_trigger_build_args(FunctionCallInfo fcinfo) ...@@ -338,6 +338,7 @@ plperl_trigger_build_args(FunctionCallInfo fcinfo)
if (TRIGGER_FIRED_BY_INSERT(tdata->tg_event)) if (TRIGGER_FIRED_BY_INSERT(tdata->tg_event))
{ {
event = "INSERT"; event = "INSERT";
if (TRIGGER_FIRED_FOR_ROW(tdata->tg_event))
hv_store(hv, "new", 3, hv_store(hv, "new", 3,
plperl_hash_from_tuple(tdata->tg_trigtuple, tupdesc), plperl_hash_from_tuple(tdata->tg_trigtuple, tupdesc),
0); 0);
...@@ -345,6 +346,7 @@ plperl_trigger_build_args(FunctionCallInfo fcinfo) ...@@ -345,6 +346,7 @@ plperl_trigger_build_args(FunctionCallInfo fcinfo)
else if (TRIGGER_FIRED_BY_DELETE(tdata->tg_event)) else if (TRIGGER_FIRED_BY_DELETE(tdata->tg_event))
{ {
event = "DELETE"; event = "DELETE";
if (TRIGGER_FIRED_FOR_ROW(tdata->tg_event))
hv_store(hv, "old", 3, hv_store(hv, "old", 3,
plperl_hash_from_tuple(tdata->tg_trigtuple, tupdesc), plperl_hash_from_tuple(tdata->tg_trigtuple, tupdesc),
0); 0);
...@@ -352,6 +354,8 @@ plperl_trigger_build_args(FunctionCallInfo fcinfo) ...@@ -352,6 +354,8 @@ plperl_trigger_build_args(FunctionCallInfo fcinfo)
else if (TRIGGER_FIRED_BY_UPDATE(tdata->tg_event)) else if (TRIGGER_FIRED_BY_UPDATE(tdata->tg_event))
{ {
event = "UPDATE"; event = "UPDATE";
if (TRIGGER_FIRED_FOR_ROW(tdata->tg_event))
{
hv_store(hv, "old", 3, hv_store(hv, "old", 3,
plperl_hash_from_tuple(tdata->tg_trigtuple, tupdesc), plperl_hash_from_tuple(tdata->tg_trigtuple, tupdesc),
0); 0);
...@@ -359,14 +363,14 @@ plperl_trigger_build_args(FunctionCallInfo fcinfo) ...@@ -359,14 +363,14 @@ plperl_trigger_build_args(FunctionCallInfo fcinfo)
plperl_hash_from_tuple(tdata->tg_newtuple, tupdesc), plperl_hash_from_tuple(tdata->tg_newtuple, tupdesc),
0); 0);
} }
else {
event = "UNKNOWN";
} }
else
event = "UNKNOWN";
hv_store(hv, "event", 5, newSVpv(event, 0), 0); hv_store(hv, "event", 5, newSVpv(event, 0), 0);
hv_store(hv, "argc", 4, newSViv(tdata->tg_trigger->tgnargs), 0); hv_store(hv, "argc", 4, newSViv(tdata->tg_trigger->tgnargs), 0);
if (tdata->tg_trigger->tgnargs != 0) if (tdata->tg_trigger->tgnargs > 0)
{ {
AV *av = newAV(); AV *av = newAV();
for (i=0; i < tdata->tg_trigger->tgnargs; i++) for (i=0; i < tdata->tg_trigger->tgnargs; i++)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment