From: | Alvaro Herrera <alvherre(at)commandprompt(dot)com> |
---|---|
To: | Rob Tester <robtester(at)gmail(dot)com> |
Cc: | pgsql-interfaces(at)postgresql(dot)org |
Subject: | Re: Trouble returning a text field from an SRF |
Date: | 2007-05-13 18:11:54 |
Message-ID: | 20070513181154.GB11750@alvh.no-ip.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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.
From | Date | Subject | |
---|---|---|---|
Next Message | Rob Tester | 2007-05-14 20:47:52 | Re: Trouble returning a text field from an SRF |
Previous Message | Rob Tester | 2007-05-12 15:26:22 | Trouble returning a text field from an SRF |