"Michael Enke" <[EMAIL PROTECTED]> writes:
> I created a C function:
> extern Datum test_arg(PG_FUNCTION_ARGS);
> PG_FUNCTION_INFO_V1(test_arg);
> Datum test_arg(PG_FUNCTION_ARGS) {
>   elog(INFO, "arg: %s", VARDATA(PG_GETARG_TEXT_P(0)));
>   PG_RETURN_INT16(0);

The VARDATA of a TEXT datum is not a C string; in particular it is not
guaranteed to be null-terminated.  This is an error in your code not
a bug.

The usual way to get a C string from a TEXT datum is to call textout,
eg

        str = DatumGetCString(DirectFunctionCall1(textout, datumval));

                        regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Reply via email to