Re: C function accepting/returning cstring vs. text - Mailing list pgsql-hackers

From Ivan Sergio Borgonovo
Subject Re: C function accepting/returning cstring vs. text
Date
Msg-id 20100127153919.5c900086@dawn.webthatworks.it
Whole thread Raw
In response to Re: C function accepting/returning cstring vs. text  (Martijn van Oosterhout <kleptog@svana.org>)
Responses Re: C function accepting/returning cstring vs. text  (Alvaro Herrera <alvherre@commandprompt.com>)
Re: C function accepting/returning cstring vs. text  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
List pgsql-hackers
On Wed, 27 Jan 2010 14:44:02 +0100
Martijn van Oosterhout <kleptog@svana.org> wrote:

> On Wed, Jan 27, 2010 at 02:14:36PM +0100, Ivan Sergio Borgonovo
> wrote:
> > I haven't been able to understand the difference between function
> > returning cstring and text and if there is any need to be careful
> > about encoding and escaping when copying from the lexeme to a
> > buffer that will return a cstring or text.

> Well, the difference is that one is a cstring and the other is
> text. Seriously though, text is more useful if you want people to
> be able to use the result in other functions since on SQL level
> almost everything is text. cstring is needed for some APIs but it
> generally not used unless necessary.

I didn't get it.
Maybe I really chose the wrong function as an example (tsvectorout).

What's not included in "on SQL level almost everything is text"?

There are a lot of functions in contrib taking cstring input and
returning cstring output.
Are they just in the same "special" class of [type]in, [type]out
[type]recv... functions?

I've to re-read carefully
http://www.postgresql.org/docs/8.4/static/xfunc-c.html
since I discovered there may be explanations about text buffers
etc...

I discover there is a cstring_to_text function... and a
text_to_cstring_buffer too... let me see if I can find something
else...

thanks

-- 
Ivan Sergio Borgonovo
http://www.webthatworks.it



pgsql-hackers by date:

Previous
From: Tim Bunce
Date:
Subject: Re: Add on_perl_init and proper destruction to plperl [PATCH]
Next
From: Ivan Sergio Borgonovo
Date:
Subject: Re: C function accepting/returning cstring vs. text