Re: Trouble returning a text field from an SRF
От | Alvaro Herrera |
---|---|
Тема | Re: Trouble returning a text field from an SRF |
Дата | |
Msg-id | 20070513181154.GB11750@alvh.no-ip.org обсуждение исходный текст |
Ответ на | Trouble returning a text field from an SRF ("Rob Tester" <robtester@gmail.com>) |
Ответы |
Re: Trouble returning a text field from an SRF
|
Список | pgsql-interfaces |
Rob Tester escribió: > I have written several postgres extensions in the past. However,currently I > am having difficulty with an extension returning a tuple. Basically I want > to return a tuple containing an integer and a very large variable length > string. I created a type on Postgres that contains two fields (int4 and > text). Originally, I was using buildTupleFromCStrings(). My function works > fine and everything is cool, until my string becomes large. At that > point NULL is returned in my tuple (I believe that this is > because Postgres is using char type conversion on the string). So, my > question is how can I return the large string as part of my tuple? Is there > a Datum function that will allow me to convert a text* into a datum? Any > help or a push in the right direction would be appreciated. You can use things like DirectFunctionCall1(textin, CStringGetDatum(the-c-string)) which returns a Datum containing a Text with the C-string in it. I would normally try to use heap_form_tuple instead of buildTupleFromCStrings if possible, but I wouldn't think that the latter would fail on too large texts. It's hard to say what's failing without actually seeing the code anyway. Maybe the problem is failure to handle TOAST at some level. -- Alvaro Herrera http://www.CommandPrompt.com/ The PostgreSQL Company - Command Prompt, Inc.
В списке pgsql-interfaces по дате отправления: