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

Commit75d30b8

Browse files
committed
Bugfix. Remove dangerous usage of short-lived AQO memory contexts.
Using such a context we should remember about the risks:* Recursion in AQO hooks can induce accidential memory context reset.* System routines which we call from the extension, could require more long-lived memory contexts on the outside than our.
1 parent3961540 commit75d30b8

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

‎preprocessing.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,6 @@ aqo_planner(Query *parse,
128128
boolquery_is_stored= false;
129129
MemoryContextoldctx;
130130

131-
oldctx=MemoryContextSwitchTo(AQOPredictMemCtx);
132-
133131
/*
134132
* We do not work inside an parallel worker now by reason of insert into
135133
* the heap during planning. Transactions are synchronized between parallel
@@ -146,7 +144,6 @@ aqo_planner(Query *parse,
146144
* We should disable AQO for this query to remember this decision along
147145
* all execution stages.
148146
*/
149-
MemoryContextSwitchTo(oldctx);
150147
disable_aqo_for_query();
151148

152149
returncall_default_planner(parse,
@@ -176,7 +173,6 @@ aqo_planner(Query *parse,
176173
* feature space, that is processing yet (disallow invalidation
177174
* recursion, as an example).
178175
*/
179-
MemoryContextSwitchTo(oldctx);
180176
disable_aqo_for_query();
181177

182178
returncall_default_planner(parse,
@@ -188,11 +184,9 @@ aqo_planner(Query *parse,
188184
elog(DEBUG1,"AQO will be used for query '%s', class "UINT64_FORMAT,
189185
query_string ?query_string :"null string",query_context.query_hash);
190186

191-
MemoryContextSwitchTo(oldctx);
192187
oldctx=MemoryContextSwitchTo(AQOCacheMemCtx);
193188
cur_classes=lappend_uint64(cur_classes,query_context.query_hash);
194189
MemoryContextSwitchTo(oldctx);
195-
oldctx=MemoryContextSwitchTo(AQOPredictMemCtx);
196190

197191
if (aqo_mode==AQO_MODE_DISABLED)
198192
{
@@ -351,7 +345,7 @@ aqo_planner(Query *parse,
351345
INSTR_TIME_SET_CURRENT(query_context.start_planning_time);
352346
{
353347
PlannedStmt*stmt;
354-
MemoryContextSwitchTo(oldctx);
348+
355349
stmt=call_default_planner(parse,query_string,
356350
cursorOptions,boundParams);
357351

@@ -458,7 +452,6 @@ jointree_walker(Node *jtnode, void *context)
458452
staticbool
459453
isQueryUsingSystemRelation_walker(Node*node,void*context)
460454
{
461-
MemoryContextoldctx=MemoryContextSwitchTo(AQOLearnMemCtx);
462455
AQOPreWalkerCtx*ctx= (AQOPreWalkerCtx*)context;
463456

464457
if (node==NULL)
@@ -500,7 +493,6 @@ isQueryUsingSystemRelation_walker(Node *node, void *context)
500493
}
501494

502495
jointree_walker((Node*)query->jointree,context);
503-
MemoryContextSwitchTo(oldctx);
504496

505497
/* Recursively plunge into subqueries and CTEs */
506498
returnquery_tree_walker(query,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp