Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d060e92

Browse files
committed
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 9210afd commit d060e92

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
/*

src/backend/executor/nodeGatherMerge.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,6 @@ ExecEndGatherMerge(GatherMergeState *node)
290290
{
291291
ExecEndNode(outerPlanState(node)); /* let children clean up first */
292292
ExecShutdownGatherMerge(node);
293-
ExecFreeExprContext(&node->ps);
294-
if (node->ps.ps_ResultTupleSlot)
295-
ExecClearTuple(node->ps.ps_ResultTupleSlot);
296293
}
297294

298295
/* ----------------------------------------------------------------

src/backend/executor/nodeGroup.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,6 @@ ExecEndGroup(GroupState *node)
228228
{
229229
PlanState *outerPlan;
230230

231-
ExecFreeExprContext(&node->ss.ps);
232-
233-
/* clean up tuple table */
234-
ExecClearTuple(node->ss.ss_ScanTupleSlot);
235-
236231
outerPlan = outerPlanState(node);
237232
ExecEndNode(outerPlan);
238233
}

src/backend/executor/nodeHash.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -415,11 +415,6 @@ ExecEndHash(HashState *node)
415415
{
416416
PlanState *outerPlan;
417417

418-
/*
419-
* free exprcontext
420-
*/
421-
ExecFreeExprContext(&node->ps);
422-
423418
/*
424419
* shut down the subplan
425420
*/

src/backend/executor/nodeHashjoin.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -867,18 +867,6 @@ ExecEndHashJoin(HashJoinState *node)
867867
node->hj_HashTable = NULL;
868868
}
869869

870-
/*
871-
* Free the exprcontext
872-
*/
873-
ExecFreeExprContext(&node->js.ps);
874-
875-
/*
876-
* clean out the tuple table
877-
*/
878-
ExecClearTuple(node->js.ps.ps_ResultTupleSlot);
879-
ExecClearTuple(node->hj_OuterTupleSlot);
880-
ExecClearTuple(node->hj_HashTupleSlot);
881-
882870
/*
883871
* clean up subtrees
884872
*/

src/backend/executor/nodeIncrementalSort.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,11 +1079,6 @@ ExecEndIncrementalSort(IncrementalSortState *node)
10791079
{
10801080
SO_printf("ExecEndIncrementalSort: shutting down sort node\n");
10811081

1082-
/* clean out the scan tuple */
1083-
ExecClearTuple(node->ss.ss_ScanTupleSlot);
1084-
/* must drop pointer to sort result tuple */
1085-
ExecClearTuple(node->ss.ps.ps_ResultTupleSlot);
1086-
/* must drop standalone tuple slots from outer node */
10871082
ExecDropSingleTupleTableSlot(node->group_pivot);
10881083
ExecDropSingleTupleTableSlot(node->transfer_tuple);
10891084

src/backend/executor/nodeIndexonlyscan.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -380,22 +380,6 @@ ExecEndIndexOnlyScan(IndexOnlyScanState *node)
380380
node->ioss_VMBuffer = InvalidBuffer;
381381
}
382382

383-
/*
384-
* Free the exprcontext(s) ... now dead code, see ExecFreeExprContext
385-
*/
386-
#ifdef NOT_USED
387-
ExecFreeExprContext(&node->ss.ps);
388-
if (node->ioss_RuntimeContext)
389-
FreeExprContext(node->ioss_RuntimeContext, true);
390-
#endif
391-
392-
/*
393-
* clear out tuple table slots
394-
*/
395-
if (node->ss.ps.ps_ResultTupleSlot)
396-
ExecClearTuple(node->ss.ps.ps_ResultTupleSlot);
397-
ExecClearTuple(node->ss.ss_ScanTupleSlot);
398-
399383
/*
400384
* close the index relation (no-op if we didn't open it)
401385
*/

src/backend/executor/nodeIndexscan.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -794,22 +794,6 @@ ExecEndIndexScan(IndexScanState *node)
794794
indexRelationDesc = node->iss_RelationDesc;
795795
indexScanDesc = node->iss_ScanDesc;
796796

797-
/*
798-
* Free the exprcontext(s) ... now dead code, see ExecFreeExprContext
799-
*/
800-
#ifdef NOT_USED
801-
ExecFreeExprContext(&node->ss.ps);
802-
if (node->iss_RuntimeContext)
803-
FreeExprContext(node->iss_RuntimeContext, true);
804-
#endif
805-
806-
/*
807-
* clear out tuple table slots
808-
*/
809-
if (node->ss.ps.ps_ResultTupleSlot)
810-
ExecClearTuple(node->ss.ps.ps_ResultTupleSlot);
811-
ExecClearTuple(node->ss.ss_ScanTupleSlot);
812-
813797
/*
814798
* close the index relation (no-op if we didn't open it)
815799
*/

src/backend/executor/nodeLimit.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,6 @@ ExecInitLimit(Limit *node, EState *estate, int eflags)
534534
void
535535
ExecEndLimit(LimitState *node)
536536
{
537-
ExecFreeExprContext(&node->ps);
538537
ExecEndNode(outerPlanState(node));
539538
}
540539

src/backend/executor/nodeMaterial.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,6 @@ ExecInitMaterial(Material *node, EState *estate, int eflags)
239239
void
240240
ExecEndMaterial(MaterialState *node)
241241
{
242-
/*
243-
* clean out the tuple table
244-
*/
245-
ExecClearTuple(node->ss.ss_ScanTupleSlot);
246-
247242
/*
248243
* Release tuplestore resources
249244
*/

src/backend/executor/nodeMemoize.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,15 +1091,6 @@ ExecEndMemoize(MemoizeState *node)
10911091
/* Remove the cache context */
10921092
MemoryContextDelete(node->tableContext);
10931093

1094-
ExecClearTuple(node->ss.ss_ScanTupleSlot);
1095-
/* must drop pointer to cache result tuple */
1096-
ExecClearTuple(node->ss.ps.ps_ResultTupleSlot);
1097-
1098-
/*
1099-
* free exprcontext
1100-
*/
1101-
ExecFreeExprContext(&node->ss.ps);
1102-
11031094
/*
11041095
* shut down the subplan
11051096
*/

src/backend/executor/nodeMergejoin.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,17 +1643,6 @@ ExecEndMergeJoin(MergeJoinState *node)
16431643
MJ1_printf("ExecEndMergeJoin: %s\n",
16441644
"ending node processing");
16451645

1646-
/*
1647-
* Free the exprcontext
1648-
*/
1649-
ExecFreeExprContext(&node->js.ps);
1650-
1651-
/*
1652-
* clean out the tuple table
1653-
*/
1654-
ExecClearTuple(node->js.ps.ps_ResultTupleSlot);
1655-
ExecClearTuple(node->mj_MarkedTupleSlot);
1656-
16571646
/*
16581647
* shut down the subplans
16591648
*/

src/backend/executor/nodeModifyTable.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4446,17 +4446,6 @@ ExecEndModifyTable(ModifyTableState *node)
44464446
ExecDropSingleTupleTableSlot(node->mt_root_tuple_slot);
44474447
}
44484448

4449-
/*
4450-
* Free the exprcontext
4451-
*/
4452-
ExecFreeExprContext(&node->ps);
4453-
4454-
/*
4455-
* clean out the tuple table
4456-
*/
4457-
if (node->ps.ps_ResultTupleSlot)
4458-
ExecClearTuple(node->ps.ps_ResultTupleSlot);
4459-
44604449
/*
44614450
* Terminate EPQ execution if active
44624451
*/

0 commit comments

Comments
 (0)