Joe Conway <mail@joeconway.com> writes:
> Any idea wht I can't step through this? In any case, the problem seems to be
> in this section of code:
> <snip>
> if (SPI_finish() != SPI_OK_FINISH)
> elog(ERROR, "pltcl: SPI_finish() failed");
> UTF_BEGIN;
> if (fcinfo->isnull)
> retval = (Datum) 0;
> else
> retval = FunctionCall3(&prodesc->result_in_func,
> PointerGetDatum(UTF_U2E(interp->result)),
> ObjectIdGetDatum(prodesc->result_in_elem),
> Int32GetDatum(-1));
> UTF_END;
> </snip>
Oh, but of course: if you are returning NULL then this sequence fails
because it pfrees an uninitialized pointer. It's fixed in CVS tip,
where the sequence reads like
if (SPI_finish() != SPI_OK_FINISH)
elog(ERROR, "pltcl: SPI_finish() failed");
if (fcinfo->isnull)
retval = (Datum) 0;
else
{
UTF_BEGIN;
retval = FunctionCall3(&prodesc->result_in_func,
PointerGetDatum(UTF_U2E(interp->result)),
ObjectIdGetDatum(prodesc->result_in_elem),
Int32GetDatum(-1));
UTF_END;
}
The reason I failed to duplicate it here was I didn't compile with
--enable-multibyte. The bug is definitely still there in 7.2.3 if
you use multibyte.
regards, tom lane