--- plperl.c~ 2004-10-02 04:15:16.737864847 +0530 +++ plperl.c 2004-10-02 04:16:36.108850361 +0530 @@ -1519,7 +1519,7 @@ static SV * plperl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc) { int i; - SV *output; + HV *hv; Datum attr; bool isnull; char *attname; @@ -1527,31 +1527,22 @@ plperl_build_tuple_argument(HeapTuple tu HeapTuple typeTup; Oid typoutput; Oid typioparam; + int namelen; - output = sv_2mortal(newSVpv("{", 0)); + hv = newHV(); for (i = 0; i < tupdesc->natts; i++) { - /* ignore dropped attributes */ if (tupdesc->attrs[i]->attisdropped) continue; - /************************************************************ - * Get the attribute name - ************************************************************/ attname = tupdesc->attrs[i]->attname.data; - - /************************************************************ - * Get the attributes value - ************************************************************/ + namelen = strlen(attname); attr = heap_getattr(tuple, i + 1, tupdesc, &isnull); - /************************************************************ - * If it is null it will be set to undef in the hash. - ************************************************************/ - if (isnull) - { - sv_catpvf(output, "'%s' => undef,", attname); + if (isnull) { + /* Store (attname => undef) and move on. */ + hv_store(hv, attname, namelen, newSV(0), 0); continue; } @@ -1577,13 +1568,11 @@ plperl_build_tuple_argument(HeapTuple tu attr, ObjectIdGetDatum(typioparam), Int32GetDatum(tupdesc->attrs[i]->atttypmod))); - sv_catpvf(output, "'%s' => '%s',", attname, outputstr); - pfree(outputstr); + + hv_store(hv, attname, namelen, newSVpv(outputstr, 0), 0); } - sv_catpv(output, "}"); - output = perl_eval_pv(SvPV(output, PL_na), TRUE); - return output; + return sv_2mortal(newRV((SV *)hv)); }