Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3cabc67

Browse files
committed
Fix incorrect tests for undef Perl values in some places in plperl.c.
The correct test for defined-ness is SvOK(sv), not anything involvingSvTYPE. Per bug #3415 from Matt Taylor.Back-patch as far as 8.0; no apparent problem in 7.x.
1 parent7c07b13 commit3cabc67

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

‎src/pl/plperl/plperl.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**********************************************************************
22
* plperl.c - perl as a procedural language for PostgreSQL
33
*
4-
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.128 2007/04/02 03:49:41 tgl Exp $
4+
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.129 2007/06/28 17:49:59 tgl Exp $
55
*
66
**********************************************************************/
77

@@ -547,7 +547,7 @@ plperl_build_tuple_result(HV *perlhash, AttInMetadata *attinmeta)
547547
(errcode(ERRCODE_UNDEFINED_COLUMN),
548548
errmsg("Perl hash contains nonexistent column \"%s\"",
549549
key)));
550-
if (SvOK(val)&&SvTYPE(val)!=SVt_NULL)
550+
if (SvOK(val))
551551
values[attn-1]=SvPV(val,PL_na);
552552
}
553553
hv_iterinit(perlhash);
@@ -743,7 +743,7 @@ plperl_modify_tuple(HV *hvTD, TriggerData *tdata, HeapTuple otup)
743743
&typinput,&typioparam);
744744
fmgr_info(typinput,&finfo);
745745
atttypmod=tupdesc->attrs[attn-1]->atttypmod;
746-
if (SvOK(val)&&SvTYPE(val)!=SVt_NULL)
746+
if (SvOK(val))
747747
{
748748
modvalues[slotsused]=InputFunctionCall(&finfo,
749749
SvPV(val,PL_na),
@@ -1197,9 +1197,10 @@ plperl_func_handler(PG_FUNCTION_ARGS)
11971197
* If the Perl function returned an arrayref, we pretend that it
11981198
* called return_next() for each element of the array, to handle old
11991199
* SRFs that didn't know about return_next(). Any other sort of return
1200-
* value is an error.
1200+
* value is an error, except undef which means return an empty set.
12011201
*/
1202-
if (SvTYPE(perlret)==SVt_RV&&
1202+
if (SvOK(perlret)&&
1203+
SvTYPE(perlret)==SVt_RV&&
12031204
SvTYPE(SvRV(perlret))==SVt_PVAV)
12041205
{
12051206
inti=0;
@@ -1212,7 +1213,7 @@ plperl_func_handler(PG_FUNCTION_ARGS)
12121213
i++;
12131214
}
12141215
}
1215-
elseif (SvTYPE(perlret)!=SVt_NULL)
1216+
elseif (SvOK(perlret))
12161217
{
12171218
ereport(ERROR,
12181219
(errcode(ERRCODE_DATATYPE_MISMATCH),
@@ -1228,7 +1229,7 @@ plperl_func_handler(PG_FUNCTION_ARGS)
12281229
}
12291230
retval= (Datum)0;
12301231
}
1231-
elseif (SvTYPE(perlret)==SVt_NULL)
1232+
elseif (!SvOK(perlret))
12321233
{
12331234
/* Return NULL if Perl code returned undef */
12341235
if (rsi&&IsA(rsi,ReturnSetInfo))
@@ -1335,7 +1336,7 @@ plperl_trigger_handler(PG_FUNCTION_ARGS)
13351336
if (SPI_finish()!=SPI_OK_FINISH)
13361337
elog(ERROR,"SPI_finish() failed");
13371338

1338-
if (!(perlret&&SvOK(perlret)&&SvTYPE(perlret)!=SVt_NULL))
1339+
if (perlret==NULL|| !SvOK(perlret))
13391340
{
13401341
/* undef result means go ahead with original tuple */
13411342
TriggerData*trigdata= ((TriggerData*)fcinfo->context);
@@ -1900,7 +1901,7 @@ plperl_return_next(SV *sv)
19001901
Datumret;
19011902
boolisNull;
19021903

1903-
if (SvOK(sv)&&SvTYPE(sv)!=SVt_NULL)
1904+
if (SvOK(sv))
19041905
{
19051906
char*val=SvPV(sv,PL_na);
19061907

@@ -2292,7 +2293,7 @@ plperl_spi_exec_prepared(char *query, HV *attr, int argc, SV **argv)
22922293

22932294
for (i=0;i<argc;i++)
22942295
{
2295-
if (SvTYPE(argv[i])!=SVt_NULL)
2296+
if (SvOK(argv[i]))
22962297
{
22972298
argvalues[i]=InputFunctionCall(&qdesc->arginfuncs[i],
22982299
SvPV(argv[i],PL_na),
@@ -2423,7 +2424,7 @@ plperl_spi_query_prepared(char *query, int argc, SV **argv)
24232424

24242425
for (i=0;i<argc;i++)
24252426
{
2426-
if (SvTYPE(argv[i])!=SVt_NULL)
2427+
if (SvOK(argv[i]))
24272428
{
24282429
argvalues[i]=InputFunctionCall(&qdesc->arginfuncs[i],
24292430
SvPV(argv[i],PL_na),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp