I wrote:
> text *
> hello()
> {
> char data[] = "hello world";
> int32 new_text_size = VARHDRSZ + sizeof(data);
> text *new_text = (text *) palloc(new_text_size);
>
> VARSIZE(new_text) = new_text_size;
> memcpy(VARDATA(new_text), data, sizeof(data));
> return new_text;
> }
Drat. Replace sizeof(data) by strlen(data) both places, and
*then* it's right. You don't want the trailing null in the
TEXT object.
regards, tom lane