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

From Tom Lane
Subject Re: Text <-> C string
Date
Msg-id 27144.1190900934@sss.pgh.pa.us
Whole thread Raw
In response to Re: Text <-> C string  ("Brendan Jurd" <direvus@gmail.com>)
Responses Re: Text <-> C string
List pgsql-hackers
"Brendan Jurd" <direvus@gmail.com> writes:
> 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.

Mmm, but the conversions are generally not identical --- for instance,
bytea needs to do escaping/de-escaping, and I doubt that XML will stick
to dumb flat-string representation for long, and for that matter text
itself is likely to change someday for better locale support.  Where the
representations and conversions *are* identical, one can just cast.
I'd vote for keeping the names focused on text ...
        regards, tom lane


pgsql-hackers by date:

Previous
From: "Brendan Jurd"
Date:
Subject: Re: Text <-> C string
Next
From: Tom Lane
Date:
Subject: Re: [COMMITTERS] pgsql: Temporarily modify tsearch regression tests to suppress notice