Re: Trouble returning a text field from an SRF - Mailing list pgsql-interfaces

From Gregory Stark
Subject Re: Trouble returning a text field from an SRF
Date
Msg-id 87k5vbx9ti.fsf@oxford.xeocode.com
Whole thread Raw
In response to Re: Trouble returning a text field from an SRF  ("Rob Tester" <robtester@gmail.com>)
Responses Re: Trouble returning a text field from an SRF  ("Rob Tester" <robtester@gmail.com>)
List pgsql-interfaces
"Rob Tester" <robtester@gmail.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



pgsql-interfaces by date:

Previous
From: "Rob Tester"
Date:
Subject: Re: Trouble returning a text field from an SRF
Next
From: "Rob Tester"
Date:
Subject: Re: Trouble returning a text field from an SRF