|
1 | 1 | /********************************************************************** |
2 | 2 | * plperl.c - perl as a procedural language for PostgreSQL |
3 | 3 | * |
4 | | - * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.157 2009/12/31 19:41:37 tgl Exp $ |
| 4 | + * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.158 2010/01/04 20:29:59 adunstan Exp $ |
5 | 5 | * |
6 | 6 | **********************************************************************/ |
7 | 7 |
|
@@ -630,7 +630,13 @@ plperl_build_tuple_result(HV *perlhash, AttInMetadata *attinmeta) |
630 | 630 | errmsg("Perl hash contains nonexistent column \"%s\"", |
631 | 631 | key))); |
632 | 632 | if (SvOK(val)) |
633 | | -values[attn-1]=SvPV(val,PL_na); |
| 633 | +{ |
| 634 | +char*aval; |
| 635 | + |
| 636 | +aval=SvPV_nolen(val); |
| 637 | +pg_verifymbstr(aval,strlen(aval), false); |
| 638 | +values[attn-1]=aval; |
| 639 | +} |
634 | 640 | } |
635 | 641 | hv_iterinit(perlhash); |
636 | 642 |
|
@@ -829,8 +835,12 @@ plperl_modify_tuple(HV *hvTD, TriggerData *tdata, HeapTuple otup) |
829 | 835 | atttypmod=tupdesc->attrs[attn-1]->atttypmod; |
830 | 836 | if (SvOK(val)) |
831 | 837 | { |
| 838 | +char*aval; |
| 839 | + |
| 840 | +aval=SvPV_nolen(val); |
| 841 | +pg_verifymbstr(aval,strlen(aval), false); |
832 | 842 | modvalues[slotsused]=InputFunctionCall(&finfo, |
833 | | -SvPV(val,PL_na), |
| 843 | +aval, |
834 | 844 | typioparam, |
835 | 845 | atttypmod); |
836 | 846 | modnulls[slotsused]=' '; |
@@ -1125,7 +1135,7 @@ plperl_create_sub(const char *proname, const char *s, bool trusted) |
1125 | 1135 | LEAVE; |
1126 | 1136 | ereport(ERROR, |
1127 | 1137 | (errcode(ERRCODE_SYNTAX_ERROR), |
1128 | | -errmsg("%s",strip_trailing_ws(SvPV(ERRSV,PL_na))))); |
| 1138 | +errmsg("%s",strip_trailing_ws(SvPV_nolen(ERRSV))))); |
1129 | 1139 | } |
1130 | 1140 |
|
1131 | 1141 | /* |
@@ -1253,7 +1263,7 @@ plperl_call_perl_func(plperl_proc_desc *desc, FunctionCallInfo fcinfo) |
1253 | 1263 | LEAVE; |
1254 | 1264 | /* XXX need to find a way to assign an errcode here */ |
1255 | 1265 | ereport(ERROR, |
1256 | | -(errmsg("%s",strip_trailing_ws(SvPV(ERRSV,PL_na))))); |
| 1266 | +(errmsg("%s",strip_trailing_ws(SvPV_nolen(ERRSV))))); |
1257 | 1267 | } |
1258 | 1268 |
|
1259 | 1269 | retval=newSVsv(POPs); |
@@ -1309,7 +1319,7 @@ plperl_call_perl_trigger_func(plperl_proc_desc *desc, FunctionCallInfo fcinfo, |
1309 | 1319 | LEAVE; |
1310 | 1320 | /* XXX need to find a way to assign an errcode here */ |
1311 | 1321 | ereport(ERROR, |
1312 | | -(errmsg("%s",strip_trailing_ws(SvPV(ERRSV,PL_na))))); |
| 1322 | +(errmsg("%s",strip_trailing_ws(SvPV_nolen(ERRSV))))); |
1313 | 1323 | } |
1314 | 1324 |
|
1315 | 1325 | retval=newSVsv(POPs); |
@@ -1467,8 +1477,8 @@ plperl_func_handler(PG_FUNCTION_ARGS) |
1467 | 1477 | perlret=array_ret; |
1468 | 1478 | } |
1469 | 1479 |
|
1470 | | -val=SvPV(perlret,PL_na); |
1471 | | - |
| 1480 | +val=SvPV_nolen(perlret); |
| 1481 | +pg_verifymbstr(val,strlen(val), false); |
1472 | 1482 | retval=InputFunctionCall(&prodesc->result_in_func,val, |
1473 | 1483 | prodesc->result_typioparam,-1); |
1474 | 1484 | } |
@@ -1550,7 +1560,7 @@ plperl_trigger_handler(PG_FUNCTION_ARGS) |
1550 | 1560 | HeapTupletrv; |
1551 | 1561 | char*tmp; |
1552 | 1562 |
|
1553 | | -tmp=SvPV(perlret,PL_na); |
| 1563 | +tmp=SvPV_nolen(perlret); |
1554 | 1564 |
|
1555 | 1565 | if (pg_strcasecmp(tmp,"SKIP")==0) |
1556 | 1566 | trv=NULL; |
@@ -2124,8 +2134,8 @@ plperl_return_next(SV *sv) |
2124 | 2134 | sv=plperl_convert_to_pg_array(sv); |
2125 | 2135 | } |
2126 | 2136 |
|
2127 | | -val=SvPV(sv,PL_na); |
2128 | | - |
| 2137 | +val=SvPV_nolen(sv); |
| 2138 | +pg_verifymbstr(val,strlen(val), false); |
2129 | 2139 | ret=InputFunctionCall(&prodesc->result_in_func,val, |
2130 | 2140 | prodesc->result_typioparam,-1); |
2131 | 2141 | isNull= false; |
@@ -2357,7 +2367,7 @@ plperl_spi_prepare(char *query, int argc, SV **argv) |
2357 | 2367 | typIOParam; |
2358 | 2368 | int32typmod; |
2359 | 2369 |
|
2360 | | -parseTypeString(SvPV(argv[i],PL_na),&typId,&typmod); |
| 2370 | +parseTypeString(SvPV_nolen(argv[i]),&typId,&typmod); |
2361 | 2371 |
|
2362 | 2372 | getTypeInputInfo(typId,&typInput,&typIOParam); |
2363 | 2373 |
|
@@ -2516,8 +2526,12 @@ plperl_spi_exec_prepared(char *query, HV *attr, int argc, SV **argv) |
2516 | 2526 | { |
2517 | 2527 | if (SvOK(argv[i])) |
2518 | 2528 | { |
| 2529 | +char*val; |
| 2530 | + |
| 2531 | +val=SvPV_nolen(argv[i]); |
| 2532 | +pg_verifymbstr(val,strlen(val), false); |
2519 | 2533 | argvalues[i]=InputFunctionCall(&qdesc->arginfuncs[i], |
2520 | | -SvPV(argv[i],PL_na), |
| 2534 | +val, |
2521 | 2535 | qdesc->argtypioparams[i], |
2522 | 2536 | -1); |
2523 | 2537 | nulls[i]=' '; |
@@ -2647,8 +2661,12 @@ plperl_spi_query_prepared(char *query, int argc, SV **argv) |
2647 | 2661 | { |
2648 | 2662 | if (SvOK(argv[i])) |
2649 | 2663 | { |
| 2664 | +char*val; |
| 2665 | + |
| 2666 | +val=SvPV_nolen(argv[i]); |
| 2667 | +pg_verifymbstr(val,strlen(val), false); |
2650 | 2668 | argvalues[i]=InputFunctionCall(&qdesc->arginfuncs[i], |
2651 | | -SvPV(argv[i],PL_na), |
| 2669 | +val, |
2652 | 2670 | qdesc->argtypioparams[i], |
2653 | 2671 | -1); |
2654 | 2672 | nulls[i]=' '; |
|