From: | "Rob Tester" <robtester(at)gmail(dot)com> |
---|---|
To: | "'Gregory Stark'" <stark(at)enterprisedb(dot)com> |
Cc: | "'Alvaro Herrera'" <alvherre(at)commandprompt(dot)com>, <pgsql-interfaces(at)postgresql(dot)org> |
Subject: | Re: Trouble returning a text field from an SRF |
Date: | 2007-05-14 23:35:23 |
Message-ID: | 07ee01c79680$8b674650$a235d2f0$@com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-interfaces |
Thanks for the tip, I will correct that if I ever get the long strings to be
returned.
I use BlessTupleDesc() in the first SRF call as the following:
BlessTupleDesc(RelationNameGetTupleDesc("testText"));
As per a previous email testText is a Type that I created on the server
using:
CREATE TYPE testText AS
(alevel integer,
someText text);
-----Original Message-----
From: Gregory Stark [mailto:stark(at)enterprisedb(dot)com]
Sent: Monday, May 14, 2007 4:30 PM
To: Rob Tester
Cc: 'Alvaro Herrera'; pgsql-interfaces(at)postgresql(dot)org
Subject: Re: [INTERFACES] Trouble returning a text field from an SRF
"Rob Tester" <robtester(at)gmail(dot)com> writes:
> textOut=palloc(MIN_SIZE*count);
> if (textOut){
> strcpy(textOut,"TEST=>");
> for(pointCnt=0;pointCnt<count;pointCnt++){
> if (pointCnt!=0){
> strcat(wktStr,",");
> }
> sprintf(buffer,"%4.8lf %4.8lf",0.0,0.0);
> strcat(textOut,buffer);
> }
> strcat(wktStr,"==>END");
Fwiw, this isn't the cause of your 64k limit but if you're processing
thousands of data points this way you might consider rewriting it without
the
strcats. As is it's a O(n^2) algorithm. Each time through the loop it'll
have
to scan the entire string it already has built up (twice even). Instead just
keep a pointer to the end of the string and add your stuff there. You can
use
strcpy and pass it the pointer to the end, or just call sprintf directly on
that pointer.
> tuple=heap_formtuple(tupDesc, values, nulls);
I'm curious about where you got the tupDesc and what it contains.
--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2007-05-15 00:24:53 | Re: Trouble returning a text field from an SRF |
Previous Message | Gregory Stark | 2007-05-14 23:30:17 | Re: Trouble returning a text field from an SRF |