Re: Endless loop calling PL/Python set returning functions

Поиск
Список
Период
Сортировка
От Alexey Grishchenko
Тема Re: Endless loop calling PL/Python set returning functions
Дата
Msg-id CAH38_tk9UnReChD24UDcmYQy5wgBDdPO7Zc45nFQjbsEL54tXg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Endless loop calling PL/Python set returning functions  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Endless loop calling PL/Python set returning functions  (Alexey Grishchenko <agrishchenko@pivotal.io>)
Список pgsql-hackers
Tom Lane <tgl@sss.pgh.pa.us> wrote:
Alexey Grishchenko <agrishchenko@pivotal.io> writes:
> No, my fix handles this well.
> In fact, with the first function call you allocate global variables
> representing Python function input parameters, call the function and
> receive iterator over the function results. Then in a series of Postgres
> calls to PL/Python handler you just fetch next value from the iterator, you
> are not calling the Python function anymore. When the iterator reaches the
> end, PL/Python call handler deallocates the global variable representing
> function input parameter.

> Regardless of the number of parallel invocations of the same function, each
> of them in my patch would set its own input parameters to the Python
> function, call the function and receive separate iterators. When the first
> function's result iterator would reach its end, it would deallocate the
> input global variable. But it won't affect other functions as they no
> longer need to invoke any Python code.

Well, if you think that works, why not undo the global-dictionary changes
at the end of the first call, rather than later?  Then there's certainly
no overlap in their lifespan.

                        regards, tom lane

Could you elaborate more on this? In general, stack-like solution would work - if before the function call there is a global variable with the name matching input variable name, push its value to the stack, and pop it after the function execution. Would implement it tomorrow and see how it works


--

Sent from handheld device

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

Предыдущее
От: Petr Jelinek
Дата:
Сообщение: Re: WAL log only necessary part of 2PC GID
Следующее
От: Tom Lane
Дата:
Сообщение: Adjusting the API of pull_var_clause()