Tobias Florek <postgres@ibotty.net> writes:
> for my untrained eye, the code [2] looks reasonable. it does use the
> following idiom though.
> len = VARSIZE(in_text) - VARHDRSZ;
This would be okay except that the in_text value was extracted with
PG_GETARG_TEXT_PP rather than PG_GETARG_TEXT_P. That allows the
value to be a short-header Datum, which this code is not prepared for.
You could either change the wrapper functions to use PG_GETARG_TEXT_P,
or fix the subroutines to use VARDATA_ANY and VARSIZE_ANY_EXHDR
when inspecting their text* arguments.
regards, tom lane