Re: Text <-> C string

Поиск
Список
Период
Сортировка
От Brendan Jurd
Тема Re: Text <-> C string
Дата
Msg-id 37ed240d0709270641t1b680ccw553ecfdff3efc2d@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Text <-> C string  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Text <-> C string
Список 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 по дате отправления:

Предыдущее
От: Simon Riggs
Дата:
Сообщение: Re: [FEATURE REQUEST] Streaming Onlinebackup (Maybe OFFTOPIC)
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Text <-> C string