Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit579ee5d

Browse files
committed
Fix memory leak in Memoize cache key evaluation
When probing the Memoize cache to check if the current cache key valuesexist in the cache, we perform an evaluation of the expressions making upthe cache key before probing the hash table for those values. Thisoperation could leak memory as it is possible that the cache key is anexpression which requires allocation of memory, as was the case in bug17844.Here we fix this by correctly switching to the per tuple context beforeevaluating the cache expressions so that the memory is freed next time theper tuple context is reset.Bug: 17844Reported-by: Alexey ErmakovDiscussion:https://postgr.es/m/17844-d2f6f9e75a622bed@postgresql.orgBackpatch-through: 14, where Memoize was introduced
1 parente060cd5 commit579ee5d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

‎src/backend/executor/nodeMemoize.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,18 @@ prepare_probe_slot(MemoizeState *mstate, MemoizeKey *key)
289289

290290
if (key==NULL)
291291
{
292+
ExprContext*econtext=mstate->ss.ps.ps_ExprContext;
293+
MemoryContextoldcontext;
294+
295+
oldcontext=MemoryContextSwitchTo(econtext->ecxt_per_tuple_memory);
296+
292297
/* Set the probeslot's values based on the current parameter values */
293298
for (inti=0;i<numKeys;i++)
294299
pslot->tts_values[i]=ExecEvalExpr(mstate->param_exprs[i],
295-
mstate->ss.ps.ps_ExprContext,
300+
econtext,
296301
&pslot->tts_isnull[i]);
302+
303+
MemoryContextSwitchTo(oldcontext);
297304
}
298305
else
299306
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp