Subject: | Segfault in dbd_st_fetch on string fetch |
Using postgresql-server-7.4.8 perl-5.8.3 perl-DBI-1.40 and
perl-DBD-Pg-1.31-5 fetching a string using fetchrow_hashref()
segfaults in dbd_st_fetch at the line "typioparam =
getTypeIOParam(typeTup);". I think this is an off-by-one error on
attribute number. The attached patch inelegantly fixes it (it probably
ought to use SPI_ calls throughout).
Subject: | pat |
--- dbdimp.c.b4 2006-03-28 13:15:34.000000000 +0100
+++ dbdimp.c 2006-03-28 13:36:56.000000000 +0100
@@ -863,7 +863,6 @@ dbd_st_fetch (sth, imp_sth)
AV *av;
SV *sv;
Oid typoutput;
- Oid typioparam;
char * attname;
Datum attr;
char * val;
@@ -909,7 +908,6 @@ dbd_st_fetch (sth, imp_sth)
elog(ERROR, "plperl: Cache lookup for attribute '%s' type %u failed", attname, tupdesc->attrs[i]->atttypid);
}
typoutput = (Oid) (((Form_pg_type) GETSTRUCT(typeTup))->typoutput);
- typioparam = getTypeIOParam(typeTup);
ReleaseSysCache(typeTup);
@@ -932,10 +930,7 @@ dbd_st_fetch (sth, imp_sth)
break;
*/
default:
- val = DatumGetCString(OidFunctionCall3(typoutput, attr,
- ObjectIdGetDatum(typioparam),
- Int32GetDatum(tupdesc->attrs[i]->atttypmod)
- ));
+ val = SPI_getvalue(tup, tupdesc, i+1);
switch (attdesc->atttypid) {
/* chopblanks won't quite work
case CHAROID: