Skip to content

Commit ce6e2fa

Browse files
committed
plperl trigger handler tried to fetch new/old tuples even when fired
as a statement trigger :-(. Per report from Sokolov Yura.
1 parent 75112d4 commit ce6e2fa

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

src/pl/plperl/plperl.c

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* ENHANCEMENTS, OR MODIFICATIONS.
3434
*
3535
* IDENTIFICATION
36-
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.66 2005/01/11 06:08:45 tgl Exp $
36+
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.67 2005/01/14 16:25:42 tgl Exp $
3737
*
3838
**********************************************************************/
3939

@@ -338,35 +338,39 @@ plperl_trigger_build_args(FunctionCallInfo fcinfo)
338338
if (TRIGGER_FIRED_BY_INSERT(tdata->tg_event))
339339
{
340340
event = "INSERT";
341-
hv_store(hv, "new", 3,
342-
plperl_hash_from_tuple(tdata->tg_trigtuple, tupdesc),
343-
0);
341+
if (TRIGGER_FIRED_FOR_ROW(tdata->tg_event))
342+
hv_store(hv, "new", 3,
343+
plperl_hash_from_tuple(tdata->tg_trigtuple, tupdesc),
344+
0);
344345
}
345346
else if (TRIGGER_FIRED_BY_DELETE(tdata->tg_event))
346347
{
347348
event = "DELETE";
348-
hv_store(hv, "old", 3,
349-
plperl_hash_from_tuple(tdata->tg_trigtuple, tupdesc),
350-
0);
349+
if (TRIGGER_FIRED_FOR_ROW(tdata->tg_event))
350+
hv_store(hv, "old", 3,
351+
plperl_hash_from_tuple(tdata->tg_trigtuple, tupdesc),
352+
0);
351353
}
352354
else if (TRIGGER_FIRED_BY_UPDATE(tdata->tg_event))
353355
{
354356
event = "UPDATE";
355-
hv_store(hv, "old", 3,
356-
plperl_hash_from_tuple(tdata->tg_trigtuple, tupdesc),
357-
0);
358-
hv_store(hv, "new", 3,
359-
plperl_hash_from_tuple(tdata->tg_newtuple, tupdesc),
360-
0);
357+
if (TRIGGER_FIRED_FOR_ROW(tdata->tg_event))
358+
{
359+
hv_store(hv, "old", 3,
360+
plperl_hash_from_tuple(tdata->tg_trigtuple, tupdesc),
361+
0);
362+
hv_store(hv, "new", 3,
363+
plperl_hash_from_tuple(tdata->tg_newtuple, tupdesc),
364+
0);
365+
}
361366
}
362-
else {
367+
else
363368
event = "UNKNOWN";
364-
}
365369

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

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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy