pgsql: Fix plancache refcount leak after error in ExecuteQuery.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Fix plancache refcount leak after error in ExecuteQuery.
Дата
Msg-id E1ltezS-0003x8-SG@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix plancache refcount leak after error in ExecuteQuery.

When stuffing a plan from the plancache into a Portal, one is
not supposed to risk throwing an error between GetCachedPlan and
PortalDefineQuery; if that happens, the plan refcount incremented
by GetCachedPlan will be leaked.  I managed to break this rule
while refactoring code in 9dbf2b7d7.  There is no visible
consequence other than some memory leakage, and since nobody is
very likely to trigger the relevant error conditions many times
in a row, it's not surprising we haven't noticed.  Nonetheless,
it's a bug, so rearrange the order of operations to remove the
hazard.

Noted on the way to looking for a better fix for bug #17053.
This mistake is pretty old, so back-patch to all supported
branches.

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/17d962ccae33db4526d08f909eea536a2a2383cf

Modified Files
--------------
src/backend/commands/prepare.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)


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

Предыдущее
От: Tomas Vondra
Дата:
Сообщение: pgsql: Fix copying data into slots with FDW batching
Следующее
От: Michael Paquier
Дата:
Сообщение: pgsql: Remove dry-run mode from isolationtester