pgsql: Fix plpgsql's handling of "simple" expression evaluation.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Fix plpgsql's handling of "simple" expression evaluation.
Дата
Msg-id E1PBVtL-0007vI-27@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix plpgsql's handling of "simple" expression evaluation.

In general, expression execution state trees aren't re-entrantly usable,
since functions can store private state information in them.
For efficiency reasons, plpgsql tries to cache and reuse state trees for
"simple" expressions.  It can get away with that most of the time, but it
can fail if the state tree is dirty from a previous failed execution (as
in an example from Alvaro) or is being used recursively (as noted by me).

Fix by tracking whether a state tree is in use, and falling back to the
"non-simple" code path if so.  This results in a pretty considerable speed
hit when the non-simple path is taken, but the available alternatives seem
even more unpleasant because they add overhead in the simple path.  Per
idea from Heikki.

Back-patch to all supported branches.

Branch
------
REL8_4_STABLE

Details
-------
http://git.postgresql.org/gitweb?p=postgresql.git;a=commitdiff;h=f44b6fc9f1334e3f52ed3c5430e008637af59a12

Modified Files
--------------
src/pl/plpgsql/src/pl_exec.c          |   30 ++++++++++++++++++++-
src/pl/plpgsql/src/plpgsql.h          |    8 +++--
src/test/regress/expected/plpgsql.out |   47 +++++++++++++++++++++++++++++++++
src/test/regress/sql/plpgsql.sql      |   42 +++++++++++++++++++++++++++++
4 files changed, 123 insertions(+), 4 deletions(-)


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Fix plpgsql's handling of "simple" expression evaluation.
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Save a few cycles in plpgsql simple-expression initialization.