Re: C function accepting/returning cstring vs. text

From: Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: C function accepting/returning cstring vs. text
Date: 2010-01-27 14:39:19
Message-ID: 20100127153919.5c900086@dawn.webthatworks.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 27 Jan 2010 14:44:02 +0100
Martijn van Oosterhout <kleptog(at)svana(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ivan Sergio Borgonovo 2010-01-27 14:40:42 Re: C function accepting/returning cstring vs. text
Previous Message Tim Bunce 2010-01-27 14:33:18 Re: Add on_perl_init and proper destruction to plperl [PATCH]