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
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.
In response to
pgsql-interfaces by date
|Next:||From: Rob Tester||Date: 2007-05-14 20:47:52|
|Subject: Re: Trouble returning a text field from an SRF|
|Previous:||From: Rob Tester||Date: 2007-05-12 15:26:22|
|Subject: Trouble returning a text field from an SRF|