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 | 20100127141436.3fb33633@dawn.webthatworks.it Whole thread Raw |
In response to | Re: C function accepting/returning cstring vs. text ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>) |
Responses |
Re: C function accepting/returning cstring vs. text
Re: C function accepting/returning cstring vs. text Re: C function accepting/returning cstring vs. text Re: C function accepting/returning cstring vs. text Re: C function accepting/returning cstring vs. text |
List | pgsql-hackers |
On Mon, 25 Jan 2010 16:36:46 -0600 "Kevin Grittner" <Kevin.Grittner@wicourts.gov> wrote: > Ivan Sergio Borgonovo <mail@webthatworks.it> wrote: > > The README files might be a good place to start, then browse code. Is there a book? The more I read the source and the few info about it, the more I have questions that should have been answered by documenting the function or data structure in spite of looking for some code that use it and see if I can infer what is expecting, what should be the best context to use it in, if there are better candidates to do the same thing etc... > > - example of returning text (especially if size of out>in) > > - what should I take care of for encoding (what's really inside a > > tsvector, text, cstring)? > src/backend/utils/fmgr/README I just learned there is a "return all row" mode for returning set functions: " There are currently two modes in which a function can return a set result: value-per-call, or materialize. In value-per-call mode, the function returns one value each time it is called, and finally reports "done" when it has no more values to return. In materialize mode, the function's output set is instantiated in a Tuplestore object; all the values are returned in one call. Additional modes might be added in future. " There is no example of a function working in this mode. I'd guess it should be suited for quick operation and small return. But... what should be considered quick and small? When someone should use a "row at a time" function and a "return all row" function? 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. Is there any difference from function returning text and function returning cstring? Can I make direct changes to input parameters and return pointers to internal parts of these structures? Or should I always allocate my char*, make the modification there and then return my "copy"? Is there any operation that should take care of encoding when dealing with cstring or text? thanks -- Ivan Sergio Borgonovo http://www.webthatworks.it
pgsql-hackers by date: