From: | Jorge Arevalo <jorgearevalo(at)gis4free(dot)org> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | C-language functions: SRF question |
Date: | 2010-04-08 15:40:44 |
Message-ID: | p2hd321138e1004080840v3e58ba6coa0465902a9c79999@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello,
I need to code a set-returning function, but it's my first time, and
I'm not sure if my point is the right one. I'd like to know your
opinion:
My function will return an array of structs. Then, In the first call
(SRF_IS_FIRSTCALL() is true), I get the array from another function.
For the next calls, I'll need to access a position of this array, so,
I'll need to store it, and the position needed, in any place. The
place should be the user_fctx field of the FuncCallContext.
I've created a struct that will store my array of structs and an int
value, a index. In the first call, this index is 0. In next calls, I
can recover data from FuncCallContext, get the struct indexed by the
index value, build my tuple, return it and increment the index.
Is this a good way of doing it? Is it possible? And another small
question: if the memory for my array of structs is allocated inside
the function that provides me the array, should I deallocate it in the
SRF? Using pfree? It wasn't allocated by palloc...
Thanks in advance, and best regards,
Jorge
From | Date | Subject | |
---|---|---|---|
Next Message | Merlin Moncure | 2010-04-08 16:18:55 | Re: C-language functions: SRF question |
Previous Message | Corin | 2010-04-08 15:04:44 | fulltext search stemming/ spelling problems |