From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | pgsql: Fix memory leakage in plpgsql DO blocks that use cast expression |
Date: | 2023-04-24 18:20:04 |
Message-ID: | E1pr0nD-004iNT-2d@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Fix memory leakage in plpgsql DO blocks that use cast expressions.
Commit 04fe805a1 modified plpgsql so that datatype casts make use of
expressions cached by plancache.c, in place of older code where these
expression trees were managed by plpgsql itself. However, I (tgl)
forgot that we use a separate, shorter-lived cast info hashtable in
DO blocks. The new mechanism thus resulted in session-lifespan
leakage of the plancache data once a DO block containing one or more
casts terminated. To fix, split the cast hash table into two parts,
one that tracks only the plancache's CachedExpressions and one that
tracks the expression state trees generated from them. DO blocks need
their own expression state trees and hence their own version of the
second hash table, but there's no reason they can't share the
CachedExpressions with regular plpgsql functions.
Per report from Ajit Awekar. Back-patch to v12 where the issue
was introduced.
Ajit Awekar and Tom Lane
Discussion: https://postgr.es/m/CAHv6PyrNaqdvyWUspzd3txYQguFTBSnhx+m6tS06TnM+KWc_LQ@mail.gmail.com
Branch
------
REL_14_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/2ba890ce7ed2b1362174f5a6686b94dcd9628949
Modified Files
--------------
src/pl/plpgsql/src/pl_exec.c | 94 ++++++++++++++++++++++++++++++--------------
src/pl/plpgsql/src/plpgsql.h | 2 +-
2 files changed, 66 insertions(+), 30 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2023-04-24 20:03:08 | pgsql: Remove vacuum_defer_cleanup_age |
Previous Message | Tom Lane | 2023-04-24 17:01:44 | pgsql: Rename ExecAggTransReparent, and improve its documentation. |