Skip to content

Commit 9b456dd

Browse files
amitlanpull[bot]
authored andcommitted
Remove obsolete executor cleanup code
This commit removes unnecessary ExecExprFreeContext() calls in ExecEnd* routines because the actual cleanup is managed by FreeExecutorState(). With no callers remaining for ExecExprFreeContext(), this commit also removes the function. This commit also drops redundant ExecClearTuple() calls, because ExecResetTupleTable() in ExecEndPlan() already takes care of resetting and dropping all TupleTableSlots initialized with ExecInitScanTupleSlot() and ExecInitExtraTupleSlot(). After these modifications, the ExecEnd*() routines for ValuesScan, NamedTuplestoreScan, and WorkTableScan became redundant. So, this commit removes them. Reviewed-by: Robert Haas Discussion: https://postgr.es/m/CA+HiwqFGkMSge6TgC9KQzde0ohpAycLQuV7ooitEEpbKB0O_mg@mail.gmail.com
1 parent c48ee88 commit 9b456dd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+6
-419
lines changed

src/backend/executor/execProcnode.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -667,22 +667,10 @@ ExecEndNode(PlanState *node)
667667
ExecEndTableFuncScan((TableFuncScanState *) node);
668668
break;
669669

670-
case T_ValuesScanState:
671-
ExecEndValuesScan((ValuesScanState *) node);
672-
break;
673-
674670
case T_CteScanState:
675671
ExecEndCteScan((CteScanState *) node);
676672
break;
677673

678-
case T_NamedTuplestoreScanState:
679-
ExecEndNamedTuplestoreScan((NamedTuplestoreScanState *) node);
680-
break;
681-
682-
case T_WorkTableScanState:
683-
ExecEndWorkTableScan((WorkTableScanState *) node);
684-
break;
685-
686674
case T_ForeignScanState:
687675
ExecEndForeignScan((ForeignScanState *) node);
688676
break;
@@ -757,6 +745,12 @@ ExecEndNode(PlanState *node)
757745
ExecEndLimit((LimitState *) node);
758746
break;
759747

748+
/* No clean up actions for these nodes. */
749+
case T_ValuesScanState:
750+
case T_NamedTuplestoreScanState:
751+
case T_WorkTableScanState:
752+
break;
753+
760754
default:
761755
elog(ERROR, "unrecognized node type: %d", (int) nodeTag(node));
762756
break;

src/backend/executor/execUtils.c

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -638,32 +638,6 @@ tlist_matches_tupdesc(PlanState *ps, List *tlist, int varno, TupleDesc tupdesc)
638638
return true;
639639
}
640640

641-
/* ----------------
642-
* ExecFreeExprContext
643-
*
644-
* A plan node's ExprContext should be freed explicitly during executor
645-
* shutdown because there may be shutdown callbacks to call. (Other resources
646-
* made by the above routines, such as projection info, don't need to be freed
647-
* explicitly because they're just memory in the per-query memory context.)
648-
*
649-
* However ... there is no particular need to do it during ExecEndNode,
650-
* because FreeExecutorState will free any remaining ExprContexts within
651-
* the EState. Letting FreeExecutorState do it allows the ExprContexts to
652-
* be freed in reverse order of creation, rather than order of creation as
653-
* will happen if we delete them here, which saves O(N^2) work in the list
654-
* cleanup inside FreeExprContext.
655-
* ----------------
656-
*/
657-
void
658-
ExecFreeExprContext(PlanState *planstate)
659-
{
660-
/*
661-
* Per above discussion, don't actually delete the ExprContext. We do
662-
* unlink it from the plan node, though.
663-
*/
664-
planstate->ps_ExprContext = NULL;
665-
}
666-
667641

668642
/* ----------------------------------------------------------------
669643
* Scan node support

src/backend/executor/nodeAgg.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4357,16 +4357,6 @@ ExecEndAgg(AggState *node)
43574357
if (node->hashcontext)
43584358
ReScanExprContext(node->hashcontext);
43594359

4360-
/*
4361-
* We don't actually free any ExprContexts here (see comment in
4362-
* ExecFreeExprContext), just unlinking the output one from the plan node
4363-
* suffices.
4364-
*/
4365-
ExecFreeExprContext(&node->ss.ps);
4366-
4367-
/* clean up tuple table */
4368-
ExecClearTuple(node->ss.ss_ScanTupleSlot);
4369-
43704360
outerPlan = outerPlanState(node);
43714361
ExecEndNode(outerPlan);
43724362
}

src/backend/executor/nodeBitmapHeapscan.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -655,18 +655,6 @@ ExecEndBitmapHeapScan(BitmapHeapScanState *node)
655655
*/
656656
scanDesc = node->ss.ss_currentScanDesc;
657657

658-
/*
659-
* Free the exprcontext
660-
*/
661-
ExecFreeExprContext(&node->ss.ps);
662-
663-
/*
664-
* clear out tuple table slots
665-
*/
666-
if (node->ss.ps.ps_ResultTupleSlot)
667-
ExecClearTuple(node->ss.ps.ps_ResultTupleSlot);
668-
ExecClearTuple(node->ss.ss_ScanTupleSlot);
669-
670658
/*
671659
* close down subplans
672660
*/

src/backend/executor/nodeBitmapIndexscan.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,6 @@ ExecEndBitmapIndexScan(BitmapIndexScanState *node)
184184
indexRelationDesc = node->biss_RelationDesc;
185185
indexScanDesc = node->biss_ScanDesc;
186186

187-
/*
188-
* Free the exprcontext ... now dead code, see ExecFreeExprContext
189-
*/
190-
#ifdef NOT_USED
191-
if (node->biss_RuntimeContext)
192-
FreeExprContext(node->biss_RuntimeContext, true);
193-
#endif
194-
195187
/*
196188
* close the index relation (no-op if we didn't open it)
197189
*/

src/backend/executor/nodeCtescan.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -287,18 +287,6 @@ ExecInitCteScan(CteScan *node, EState *estate, int eflags)
287287
void
288288
ExecEndCteScan(CteScanState *node)
289289
{
290-
/*
291-
* Free exprcontext
292-
*/
293-
ExecFreeExprContext(&node->ss.ps);
294-
295-
/*
296-
* clean out the tuple table
297-
*/
298-
if (node->ss.ps.ps_ResultTupleSlot)
299-
ExecClearTuple(node->ss.ps.ps_ResultTupleSlot);
300-
ExecClearTuple(node->ss.ss_ScanTupleSlot);
301-
302290
/*
303291
* If I am the leader, free the tuplestore.
304292
*/

src/backend/executor/nodeCustom.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,6 @@ ExecEndCustomScan(CustomScanState *node)
129129
{
130130
Assert(node->methods->EndCustomScan != NULL);
131131
node->methods->EndCustomScan(node);
132-
133-
/* Free the exprcontext */
134-
ExecFreeExprContext(&node->ss.ps);
135-
136-
/* Clean out the tuple table */
137-
ExecClearTuple(node->ss.ps.ps_ResultTupleSlot);
138-
ExecClearTuple(node->ss.ss_ScanTupleSlot);
139132
}
140133

141134
void

src/backend/executor/nodeForeignscan.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -312,14 +312,6 @@ ExecEndForeignScan(ForeignScanState *node)
312312
/* Shut down any outer plan. */
313313
if (outerPlanState(node))
314314
ExecEndNode(outerPlanState(node));
315-
316-
/* Free the exprcontext */
317-
ExecFreeExprContext(&node->ss.ps);
318-
319-
/* clean out the tuple table */
320-
if (node->ss.ps.ps_ResultTupleSlot)
321-
ExecClearTuple(node->ss.ps.ps_ResultTupleSlot);
322-
ExecClearTuple(node->ss.ss_ScanTupleSlot);
323315
}
324316

325317
/* ----------------------------------------------------------------

src/backend/executor/nodeFunctionscan.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -523,28 +523,13 @@ ExecEndFunctionScan(FunctionScanState *node)
523523
{
524524
int i;
525525

526-
/*
527-
* Free the exprcontext
528-
*/
529-
ExecFreeExprContext(&node->ss.ps);
530-
531-
/*
532-
* clean out the tuple table
533-
*/
534-
if (node->ss.ps.ps_ResultTupleSlot)
535-
ExecClearTuple(node->ss.ps.ps_ResultTupleSlot);
536-
ExecClearTuple(node->ss.ss_ScanTupleSlot);
537-
538526
/*
539527
* Release slots and tuplestore resources
540528
*/
541529
for (i = 0; i < node->nfuncs; i++)
542530
{
543531
FunctionScanPerFuncState *fs = &node->funcstates[i];
544532

545-
if (fs->func_slot)
546-
ExecClearTuple(fs->func_slot);
547-
548533
if (fs->tstore != NULL)
549534
{
550535
tuplestore_end(node->funcstates[i].tstore);

src/backend/executor/nodeGather.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,6 @@ ExecEndGather(GatherState *node)
250250
{
251251
ExecEndNode(outerPlanState(node)); /* let children clean up first */
252252
ExecShutdownGather(node);
253-
ExecFreeExprContext(&node->ps);
254-
if (node->ps.ps_ResultTupleSlot)
255-
ExecClearTuple(node->ps.ps_ResultTupleSlot);
256253
}
257254

258255
/*

0 commit comments

Comments
 (0)