Re: Text <-> C string - Mailing list pgsql-hackers

From Brendan Jurd
Subject Re: Text <-> C string
Date
Msg-id 37ed240d0709270641t1b680ccw553ecfdff3efc2d@mail.gmail.com
Whole thread Raw
In response to Re: Text <-> C string  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Text <-> C string
List pgsql-hackers
On 9/22/07, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> On grounds of code-space savings I think it might be worth making
> these things be simple functions declared in builtins.h; that would
> also make it much easier to change their implementations.

I've noticed that this pattern isn't exclusive to the text type; other
varlena types like bytea and xmltype seem to have a common requirement
to translate to and fro C strings for various jobs.

Does it make sense to go one level lower, and make these functions
work for any varlena?

So far, I've got the following functions doing the work:

char * text_cstring(text *t)
char * text_cstring_limit(text *t, int len)
text * cstring_text(char *s)

It wouldn't be difficult at this point to make those functions
'varlena' rather than 'text', and then bytea and xmltype (and any
other future types that want to inherit from varlena) can take
advantage of them.

Thanks for your time,
BJ


pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: [FEATURE REQUEST] Streaming Onlinebackup (Maybe OFFTOPIC)
Next
From: Tom Lane
Date:
Subject: Re: Text <-> C string