From: Tom Lane Date: Thu, 28 Jun 2007 17:50:24 +0000 (+0000) Subject: Fix incorrect tests for undef Perl values in some places in plperl.c. X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=b7a7c8cc8ae4d57d03e8a6abce25c727ca842dff;p=users%2Fbernd%2Fpostgres.git Fix incorrect tests for undef Perl values in some places in plperl.c. The correct test for defined-ness is SvOK(sv), not anything involving SvTYPE. Per bug #3415 from Matt Taylor. Back-patch as far as 8.0; no apparent problem in 7.x. --- diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c index 2c2ea0e43c..5a978a8178 100644 --- a/src/pl/plperl/plperl.c +++ b/src/pl/plperl/plperl.c @@ -385,7 +385,7 @@ plperl_build_tuple_result(HV *perlhash, AttInMetadata *attinmeta) (errcode(ERRCODE_UNDEFINED_COLUMN), errmsg("Perl hash contains nonexistent column \"%s\"", key))); - if (SvOK(val) && SvTYPE(val) != SVt_NULL) + if (SvOK(val)) values[attn - 1] = SvPV(val, PL_na); } hv_iterinit(perlhash); @@ -561,7 +561,7 @@ plperl_modify_tuple(HV *hvTD, TriggerData *tdata, HeapTuple otup) (errcode(ERRCODE_UNDEFINED_COLUMN), errmsg("Perl hash contains nonexistent column \"%s\"", key))); - if (SvOK(val) && SvTYPE(val) != SVt_NULL) + if (SvOK(val)) { Oid typinput; Oid typioparam; @@ -949,7 +949,7 @@ plperl_func_handler(PG_FUNCTION_ARGS) if (SPI_finish() != SPI_OK_FINISH) elog(ERROR, "SPI_finish() failed"); - if (!(perlret && SvOK(perlret) && SvTYPE(perlret) != SVt_NULL)) + if (!(perlret && SvOK(perlret))) { /* return NULL if Perl code returned undef */ ReturnSetInfo *rsi = (ReturnSetInfo *) fcinfo->resultinfo; @@ -1053,7 +1053,7 @@ plperl_func_handler(PG_FUNCTION_ARGS) svp = av_fetch(ret_av, funcctx->call_cntr, FALSE); Assert(svp != NULL); - if (SvOK(*svp) && SvTYPE(*svp) != SVt_NULL) + if (SvOK(*svp)) { char *val = SvPV(*svp, PL_na); @@ -1159,7 +1159,7 @@ plperl_trigger_handler(PG_FUNCTION_ARGS) if (SPI_finish() != SPI_OK_FINISH) elog(ERROR, "SPI_finish() failed"); - if (!(perlret && SvOK(perlret) && SvTYPE(perlret) != SVt_NULL)) + if (perlret == NULL || !SvOK(perlret)) { /* undef result means go ahead with original tuple */ TriggerData *trigdata = ((TriggerData *) fcinfo->context);