pgsql: Per a bug report from Theo Schlossnagle, plperl_return_next()

Поиск
Список
Период
Сортировка
От neilc@postgresql.org (Neil Conway)
Тема pgsql: Per a bug report from Theo Schlossnagle, plperl_return_next()
Дата
Msg-id 20060128032819.391169DC93C@postgresql.org
обсуждение исходный текст
Список pgsql-committers
Log Message:
-----------
Per a bug report from Theo Schlossnagle, plperl_return_next() leaks
memory in the executor's per-query memory context. It also inefficient:
it invokes get_call_result_type() and TupleDescGetAttInMetadata() for
every call to return_next, rather than invoking them once (per PL/Perl
function call) and memoizing the result.

This patch makes the following changes:

- refactor the code to include all the "per PL/Perl function call" data
inside a single struct, "current_call_data". This means we don't need to
save and restore N pointers for every recursive call into PL/Perl, we
can just save and restore one.

- lookup the return type metadata needed by plperl_return_next() once,
and then stash it in "current_call_data", so as to avoid doing the
lookup for every call to return_next.

- create a temporary memory context in which to evaluate the return
type's input functions. This memory context is reset for each call to
return_next.

The patch appears to fix the memory leak, and substantially reduces
the overhead imposed by return_next.

Tags:
----
REL8_1_STABLE

Modified Files:
--------------
    pgsql/src/pl/plperl:
        plperl.c (r1.94.2.3 -> r1.94.2.4)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/pl/plperl/plperl.c.diff?r1=1.94.2.3&r2=1.94.2.4)

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

Предыдущее
От: neilc@postgresql.org (Neil Conway)
Дата:
Сообщение: pgsql: Per a bug report from Theo Schlossnagle, plperl_return_next()
Следующее
От: adunstan@postgresql.org (Andrew Dunstan)
Дата:
Сообщение: pgsql: Undo perl's nasty locale setting on Windows.