"Pavel Stehule" <pavel.stehule@hotmail.com> writes:
>
> Datum *const_fce(PG_FUNCTION_ARGS)
> {
> text *txt = palloc(5 + VARHDRSZ);
> memcpy(VARDATA(txt), "pavel", 5);
> VARATT_SIZE(txt) = 5 + VARHDRSZ;
>
> PG_RETURN_TEXT_P(txt);
> }
Much better practice is to use the input function of the data type you want to
convert to:
{text *txt = DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum("pavel")));PG_RETURN_TEXT_P(txt);
}
-- Gregory Stark EnterpriseDB http://www.enterprisedb.com