"Pavel Stehule" <[EMAIL PROTECTED]> 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);
}
Generally we want to do something with text value (concat, trim, ..) and
then call textin isn't practic. Respective, for bussness processes
implemented in C is textin and similar functions right. For string toolkit
is better direct work with VARLENA struct.
Regards and thank you note
Pavel
_________________________________________________________________
Emotikony a pozadi programu MSN Messenger ozivi vasi konverzaci.
http://messenger.msn.cz/
---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly