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

Commitc058fc2

Browse files
committed
Rationalize expression context reset in ExecModifyTable().
The current pattern of reseting expressions both inExecProcessReturning() and ExecOnConflictUpdate() makes it harder thannecessary to reason about memory lifetimes. It also requiresmaterializing slots unnecessarily, although this patch doesn't takeadvantage of the fact that that's not necessary anymore.Instead reset the expression context once for each input tuple.Author: Ashutosh BapatDiscussion:https://postgr.es/m/20181105210039.hh4vvi4vwoq5ba2q@alap3.anarazel.de
1 parent6a74441 commitc058fc2

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

‎src/backend/executor/nodeModifyTable.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,6 @@ ExecProcessReturning(ResultRelInfo *resultRelInfo,
163163
ProjectionInfo*projectReturning=resultRelInfo->ri_projectReturning;
164164
ExprContext*econtext=projectReturning->pi_exprContext;
165165

166-
/*
167-
* Reset per-tuple memory context to free any expression evaluation
168-
* storage allocated in the previous cycle.
169-
*/
170-
ResetExprContext(econtext);
171-
172166
/* Make tuple and any needed join variables available to ExecProject */
173167
if (tupleSlot)
174168
econtext->ecxt_scantuple=tupleSlot;
@@ -1453,13 +1447,7 @@ ExecOnConflictUpdate(ModifyTableState *mtstate,
14531447
elog(ERROR,"unrecognized heap_lock_tuple status: %u",test);
14541448
}
14551449

1456-
/*
1457-
* Success, the tuple is locked.
1458-
*
1459-
* Reset per-tuple memory context to free any expression evaluation
1460-
* storage allocated in the previous cycle.
1461-
*/
1462-
ResetExprContext(econtext);
1450+
/* Success, the tuple is locked. */
14631451

14641452
/*
14651453
* Verify that the tuple is visible to our MVCC snapshot if the current
@@ -2028,6 +2016,14 @@ ExecModifyTable(PlanState *pstate)
20282016
*/
20292017
ResetPerTupleExprContext(estate);
20302018

2019+
/*
2020+
* Reset per-tuple memory context used for processing on conflict and
2021+
* returning clauses, to free any expression evaluation storage
2022+
* allocated in the previous cycle.
2023+
*/
2024+
if (pstate->ps_ExprContext)
2025+
ResetExprContext(pstate->ps_ExprContext);
2026+
20312027
planSlot=ExecProcNode(subplanstate);
20322028

20332029
if (TupIsNull(planSlot))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp