Re: C function woes

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Chris Hayner <hayner80(at)astro(dot)ocis(dot)temple(dot)edu>, PostgreSQL-General <pgsql-general(at)postgresql(dot)org>
Subject: Re: C function woes
Date: 2001-02-21 16:36:52
Message-ID: Pine.LNX.4.30.0102211735230.1381-100000@peter.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tom Lane writes:

> 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;
> }

Is it good practice to scribble around in data type internals? Why not

text *
hello()
{
return textin("hello world");
}

--
Peter Eisentraut peter_e(at)gmx(dot)net http://yi.org/peter-e/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Peter Eisentraut 2001-02-21 16:46:39 Re: pg_shadow.passwd versus pg_hba.conf password passwd
Previous Message Gregory Wood 2001-02-21 16:32:09 Re: Deferred NOT NULL?