Hi !

I'm trying to write a window function in C .

In the function I'm using a tuplesort to sort the window data and then do
some processing.
Now when I'm running the function I get this: 'WARNING:  temporary file
leak: File 43 still referenced'
The warning comes from my failure to call tuplesort_end at the appropriate
time.
>From the beginning I thought that calling tuplesort_end when current_pos in
the window approched WinGetPartitionRowCount would do it.
That seemed to work at first but when I put a limit-clause in the query
that doesn't work.
So I think I need to use some callback mechanism to get that to work.
I've found some reference in the postgres source code to
RegisterExprContextCallback which seemed promising but I have no idea how
to get the right expression context to put in as the first argument to that
function.

So my question is, how do I shut down the tuplesort properly after the last
call to my window function ?

I'm running "PostgreSQL 9.3.5 on i686-pc-linux-gnu, compiled by
gcc-4.4.real (Debian 4.4.5-8) 4.4.5, 32-bit"

Best Regards
Dan S

Reply via email to