char *
SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber)
{
- char *result;
- Datum origval,
- val;
+ Datum val;
bool isnull;
Oid typoid,
foutoid;
return NULL;
}
- origval = heap_getattr(tuple, fnumber, tupdesc, &isnull);
+ val = heap_getattr(tuple, fnumber, tupdesc, &isnull);
if (isnull)
return NULL;
getTypeOutputInfo(typoid, &foutoid, &typisvarlena);
- /*
- * If we have a toasted datum, forcibly detoast it here to avoid memory
- * leakage inside the type's output routine.
- */
- if (typisvarlena)
- val = PointerGetDatum(PG_DETOAST_DATUM(origval));
- else
- val = origval;
-
- result = OidOutputFunctionCall(foutoid, val);
-
- /* Clean up detoasted copy, if any */
- if (val != origval)
- pfree(DatumGetPointer(val));
-
- return result;
+ return OidOutputFunctionCall(foutoid, val);
}
Datum