Skip site navigation (1) Skip section navigation (2)

Re: Text <-> C string

From: "Brendan Jurd" <direvus(at)gmail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Gregory Stark" <stark(at)enterprisedb(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Text <-> C string
Date: 2007-09-27 13:41:52
Message-ID: 37ed240d0709270641t1b680ccw553ecfdff3efc2d@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
On 9/22/07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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

In response to

Responses

pgsql-hackers by date

Next:From: Tom LaneDate: 2007-09-27 13:48:54
Subject: Re: Text <-> C string
Previous:From: Brendan JurdDate: 2007-09-27 12:53:06
Subject: Re: Eliminate more detoast copies for packed varlenas

pgsql-patches by date

Next:From: Tom LaneDate: 2007-09-27 13:48:54
Subject: Re: Text <-> C string
Previous:From: Brendan JurdDate: 2007-09-27 12:53:06
Subject: Re: Eliminate more detoast copies for packed varlenas

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group