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

Commit9cf37a5

Browse files
committed
Plug leak in BuildTupleHashTable by creating ExprContext in correct context.
Inbf6c614 I added a expr context to evaluate the groupingexpression. Unfortunately the code I added initialized them while inthe calling context, rather the table context. Additionally, I usedCreateExprContext() rather than CreateStandaloneExprContext(), whichcreates the econtext in the estate's query context.Fix that by using CreateStandaloneExprContext when in the table'stablecxt. As we rely on the memory being freed by a memory contextreset that means that the econtext's shutdown callbacks aren't beingcalled, but that seems ok as the expressions are tightly controlleddue to ExecBuildGroupingEqual().Bug: #15592Reported-By: Dmitry MarakasovAuthor: Andres FreundDiscussion:https://postgr.es/m/20190114222838.h6r3fuyxjxkykf6t@alap3.anarazel.deBackpatch: 11, where I broke this inbf6c614
1 parent5996cfc commit9cf37a5

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

‎src/backend/executor/execGrouping.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,17 @@ BuildTupleHashTable(PlanState *parent,
208208
hashtable->tab_eq_func=ExecBuildGroupingEqual(inputDesc,inputDesc,
209209
numCols,
210210
keyColIdx,eqfuncoids,
211-
parent);
211+
NULL);
212212

213-
MemoryContextSwitchTo(oldcontext);
213+
/*
214+
* While not pretty, it's ok to not shut down this context, but instead
215+
* rely on the containing memory context being reset, as
216+
* ExecBuildGroupingEqual() only builds a very simple expression calling
217+
* functions (i.e. nothing that'd employ RegisterExprContextCallback()).
218+
*/
219+
hashtable->exprcontext=CreateStandaloneExprContext();
214220

215-
hashtable->exprcontext=CreateExprContext(parent->state);
221+
MemoryContextSwitchTo(oldcontext);
216222

217223
returnhashtable;
218224
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp