Re: question about window function in C

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: question about window function in C
Дата
Msg-id 1612.1419616654@sss.pgh.pa.us
обсуждение исходный текст
Ответ на question about window function in C  (Dan S <strd911@gmail.com>)
Ответы Re: question about window function in C  (Dan S <strd911@gmail.com>)
Список pgsql-general
Dan S <strd911@gmail.com> writes:
> 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.

Hmm ... why do you feel you need to do that?  The window function's input
should already be sorted according to the window specification.

> 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.

Unsurprising.

> 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.

I don't think there is one :-(.  WindowAgg has a per-input-tuple econtext,
and a per-output-tuple econtext, but what you'd need for this is a
partition-lifespan econtext, which doesn't exist.

It's possible that we could promote the "partcontext" memory context into
a full econtext so as to support this sort of behavior.  But I'd want to
see a reasonably convincing use-case for it.

            regards, tom lane


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

Предыдущее
От: Dan S
Дата:
Сообщение: question about window function in C
Следующее
От: Edson Carlos Ericksson Richter
Дата:
Сообщение: How to install pgAdmin 1.20 on Mint Rebecca?