"Glen W. Mabey" <Glen(dot)Mabey(at)swri(dot)org> writes:
> Is there somewhere that I am not adequately checking for an error?
1. You're passing SPI_getbinval an uninitialized bool pointer.
2. You're discarding its result, which you need.
3. You're not checking for a null, and the error check you do have
is wrong/redundant.
4. Use DatumGetTextP(), not DatumGetPointer nor PG_DETOAST_DATUM.
regards, tom lane