Re: Writing SRF

Поиск
Список
Период
Сортировка
От Jorge Arevalo
Тема Re: Writing SRF
Дата
Msg-id k2id321138e1004291045q6e2c78ffl10d1e4ef8b2627ec@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Writing SRF  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Writing SRF  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Writing SRF  (Martin Gainty <mgainty@hotmail.com>)
Список pgsql-general
On Thu, Apr 29, 2010 at 3:56 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Jorge Arevalo <jorgearevalo@gis4free.org> writes:
>> Yes. For example, the function expects 2 arguments, and it's called
>> with 2 arguments: 1 composite type (following this format
>> https://svn.osgeo.org/postgis/spike/wktraster/doc/RFC1-SerializedFormat)
>> and one integer. But PG_NARGS() returns a really big value (16297)
>> when I first check the number of arguments at the beginning of the
>> function. Has sense?
>
> Given only that data point, I would guess that you forgot to mark the
> function as being called with V1 protocol (PG_FUNCTION_INFO_V1).
>
>                        regards, tom lane
>

Many thanks! That was one of my errors. Another one was this:

char szDataPointer[10];
sprintf(szDataPointer, "%p", a_pointer);

These lines caused a memory error. I changed them for:

char * pszDataPointer;
pszDataPointer = (char *)allocator(10 * sizeof(char));
sprintf(pszDataPointer, "%p", a_pointer);

Meaning "allocator" a memory allocator in a valid memory context for PostgreSQL.

And seems to work :-). Is the static memory "dangerous" in a
PostgreSQL memory context?

Thanks again!
Jorge

В списке pgsql-general по дате отправления:

Предыдущее
От: Oliver Kohll - Mailing Lists
Дата:
Сообщение: Re: Cumulative count (running total) window fn
Следующее
От: John Gage
Дата:
Сообщение: Re: [SQL] Tsearch not searching 'Y'