/* ---------------------------------------------------------------- * ExecEndExternalScan * * frees any storage allocated through C routines. * ---------------------------------------------------------------- */ void ExecEndExternalScan(ExternalScanState *node) { /* * Free the exprcontext */ ExecFreeExprContext(&node->ss.ps); /* * clean out the tuple table */ ExecClearTuple(node->ss.ps.ps_ResultTupleSlot); ExecClearTuple(node->ss.ss_ScanTupleSlot); ExecEagerFreeExternalScan(node); pfree(node->ess_ScanDesc); /* * close the external relation. * * MPP-8040: make sure we don't close it if it hasn't completed setup, or * if we've already closed it. */ if (node->ss.ss_currentRelation) { Relation relation = node->ss.ss_currentRelation; node->ss.ss_currentRelation = NULL; ExecCloseScanRelation(relation); } EndPlanStateGpmonPkt(&node->ss.ps); }
/* ---------------------------------------------------------------- * ExecEndSubqueryScan * * frees any storage allocated through C routines. * ---------------------------------------------------------------- */ void ExecEndSubqueryScan(SubqueryScanState *node) { MemoryContext oldcontext; /* * Free the exprcontext */ ExecFreeExprContext(&node->ss.ps); /* * clean out the upper tuple table */ ExecClearTuple(node->ss.ps.ps_ResultTupleSlot); node->ss.ss_ScanTupleSlot = NULL; /* not ours to clear */ /* * close down subquery */ oldcontext = MemoryContextSwitchTo(node->sss_SubEState->es_query_cxt); ExecEndPlan(node->subplan, node->sss_SubEState); MemoryContextSwitchTo(oldcontext); FreeExecutorState(node->sss_SubEState); }
/* ---------------------------------------------------------------- * ExecEndAppendOnlyScan * * frees any storage allocated through C routines. * ---------------------------------------------------------------- */ void ExecEndAppendOnlyScan(AppendOnlyScanState *node) { Relation relation; AppendOnlyScanDesc scanDesc; /* * get information from node */ relation = node->ss.ss_currentRelation; scanDesc = node->aos_ScanDesc; /* * Free the exprcontext */ ExecFreeExprContext(&node->ss.ps); /* * clean out the tuple table */ ExecClearTuple(node->ss.ps.ps_ResultTupleSlot); ExecClearTuple(node->ss.ss_ScanTupleSlot); ExecEagerFreeAppendOnlyScan(node); /* * close the heap relation. */ ExecCloseScanRelation(relation); EndPlanStateGpmonPkt(&node->ss.ps); }
/* ---------------------------------------------------------------- * ExecEndSeqScan * * frees any storage allocated through C routines. * ---------------------------------------------------------------- */ void ExecEndSeqScan(SeqScanState *node) { Relation relation; /* * get information from node */ relation = node->ss_currentRelation; /* * Free the exprcontext */ ExecFreeExprContext(&node->ps); /* * clean out the tuple table */ ExecClearTuple(node->ps.ps_ResultTupleSlot); ExecClearTuple(node->ss_ScanTupleSlot); ExecEagerFreeSeqScan(node); /* * close the heap relation. */ ExecCloseScanRelation(relation); /* gpmon */ EndPlanStateGpmonPkt(&node->ps); }
/* ---------------------------------------------------------------- * ExecEndNestLoop * * closes down scans and frees allocated storage * ---------------------------------------------------------------- */ void ExecEndNestLoop(NestLoopState *node) { NL1_printf("ExecEndNestLoop: %s\n", "ending node processing"); /* * Free the exprcontext */ ExecFreeExprContext(&node->js.ps); /* * clean out the tuple table */ ExecClearTuple(node->js.ps.ps_ResultTupleSlot); /* * close down subplans */ ExecEndNode(outerPlanState(node)); ExecEndNode(innerPlanState(node)); NL1_printf("ExecEndNestLoop: %s\n", "node processing ended"); }
/* ---------------------------------------------------------------- * ExecEndSeqScan * * frees any storage allocated through C routines. * ---------------------------------------------------------------- */ void ExecEndSeqScan(SeqScanState *node) { Relation relation; HeapScanDesc scanDesc; /* * get information from node */ relation = node->ss_currentRelation; scanDesc = node->ss_currentScanDesc; /* * Free the exprcontext */ ExecFreeExprContext(&node->ps); /* * clean out the tuple table */ ExecClearTuple(node->ps.ps_ResultTupleSlot); ExecClearTuple(node->ss_ScanTupleSlot); /* * close heap scan */ heap_endscan(scanDesc); /* * close the heap relation. */ ExecCloseScanRelation(relation); }
/* ---------------------------------------------------------------- * ExecEndSubqueryScan * * frees any storage allocated through C routines. * ---------------------------------------------------------------- */ void ExecEndSubqueryScan(SubqueryScanState *node) { /* * Free the exprcontext */ ExecFreeExprContext(&node->ss.ps); /* * clean out the upper tuple table */ if (node->ss.ss_ScanTupleSlot != NULL) { ExecClearTuple(node->ss.ps.ps_ResultTupleSlot); node->ss.ss_ScanTupleSlot = NULL; /* not ours to clear */ } /* gpmon */ EndPlanStateGpmonPkt(&node->ss.ps); /* * close down subquery */ ExecEndNode(node->subplan); }
/* ---------------------------------------------------------------- * ExecEndLimit * * This shuts down the subplan and frees resources allocated * to this node. * ---------------------------------------------------------------- */ void ExecEndLimit(LimitState *node) { ExecFreeExprContext(&node->ps); ExecEndNode(outerPlanState(node)); EndPlanStateGpmonPkt(&node->ps); }
/* ---------------------------------------------------------------- * ExecEndGather * * frees any storage allocated through C routines. * ---------------------------------------------------------------- */ void ExecEndGather(GatherState *node) { ExecShutdownGather(node); ExecFreeExprContext(&node->ps); ExecClearTuple(node->ps.ps_ResultTupleSlot); ExecEndNode(outerPlanState(node)); }
/* ---------------------------------------------------------------- * ExecEndGatherMerge * * frees any storage allocated through C routines. * ---------------------------------------------------------------- */ void ExecEndGatherMerge(GatherMergeState *node) { ExecEndNode(outerPlanState(node)); /* let children clean up first */ ExecShutdownGatherMerge(node); ExecFreeExprContext(&node->ps); ExecClearTuple(node->ps.ps_ResultTupleSlot); }
/* ---------------------------------------------------------------- * ExecEndLimit * * This shuts down the subplan and frees resources allocated * to this node. * ---------------------------------------------------------------- */ void ExecEndLimit(LimitState *node) { ExecFreeExprContext(&node->ps); /* clean up tuple table */ ExecClearTuple(node->ps.ps_ResultTupleSlot); ExecEndNode(outerPlanState(node)); }
/* Release Resources Requested by nodeDML. */ void ExecEndDML(DMLState *node) { /* Release explicitly the TupleDesc for result relation */ ReleaseTupleDesc(node->junkfilter->jf_cleanTupType); ExecFreeExprContext(&node->ps); ExecClearTuple(node->ps.ps_ResultTupleSlot); ExecClearTuple(node->cleanedUpSlot); ExecEndNode(outerPlanState(node)); EndPlanStateGpmonPkt(&node->ps); }
/* * FreeScanRelationInternal * Free ScanState common variables initialized in InitScanStateInternal. */ void FreeScanRelationInternal(ScanState *scanState, bool closeCurrentRelation) { ExecFreeExprContext(&scanState->ps); ExecClearTuple(scanState->ps.ps_ResultTupleSlot); ExecClearTuple(scanState->ss_ScanTupleSlot); if (closeCurrentRelation) { ExecCloseScanRelation(scanState->ss_currentRelation); } }
/* ---------------------------------------------------------------- * ExecEndBitmapHeapScan * ---------------------------------------------------------------- */ void ExecEndBitmapHeapScan(BitmapHeapScanState *node) { Relation relation; HeapScanDesc scanDesc; /* * extract information from the node */ relation = node->ss.ss_currentRelation; scanDesc = node->ss.ss_currentScanDesc; /* * Free the exprcontext */ ExecFreeExprContext(&node->ss.ps); /* * clear out tuple table slots */ ExecClearTuple(node->ss.ps.ps_ResultTupleSlot); ExecClearTuple(node->ss.ss_ScanTupleSlot); /* * close down subplans */ ExecEndNode(outerPlanState(node)); /* * release bitmap if any */ if (node->tbmiterator) tbm_end_iterate(node->tbmiterator); if (node->prefetch_iterator) tbm_end_iterate(node->prefetch_iterator); if (node->tbm) tbm_free(node->tbm); if (node->shared_tbmiterator) tbm_end_shared_iterate(node->shared_tbmiterator); if (node->shared_prefetch_iterator) tbm_end_shared_iterate(node->shared_prefetch_iterator); /* * close heap scan */ heap_endscan(scanDesc); /* * close the heap relation. */ ExecCloseScanRelation(relation); }
/* ---------------------------------------------------------------- * ExecEndBitmapHeapScan * ---------------------------------------------------------------- */ void ExecEndBitmapHeapScan(BitmapHeapScanState *node) { Relation relation; HeapScanDesc scanDesc; /* * extract information from the node */ relation = node->ss.ss_currentRelation; scanDesc = node->ss.ss_currentScanDesc; /* * Free the exprcontext */ ExecFreeExprContext(&node->ss.ps); /* * clear out tuple table slots */ ExecClearTuple(node->ss.ps.ps_ResultTupleSlot); ExecClearTuple(node->ss.ss_ScanTupleSlot); /* * close down subplans */ ExecEndNode(outerPlanState(node)); /* * release bitmap if any */ if (node->tbm) tbm_free(node->tbm); if (node->odbm) odbm_free(node->odbm); /* * close heap scan */ heap_endscan(scanDesc); /* * close the heap relation. * * Currently, we do not release the AccessShareLock acquired by * ExecInitBitmapHeapScan. This lock should be held till end of * transaction. (There is a faction that considers this too much locking, * however.) */ heap_close(relation, NoLock); }
/* ---------------------------------------------------------------- * ExecEndSetOp * * This shuts down the subplan and frees resources allocated * to this node. * ---------------------------------------------------------------- */ void ExecEndSetOp(SetOpState *node) { /* clean up tuple table */ ExecClearTuple(node->ps.ps_ResultTupleSlot); /* free subsidiary stuff including hashtable */ if (node->tableContext) MemoryContextDelete(node->tableContext); ExecFreeExprContext(&node->ps); ExecEndNode(outerPlanState(node)); }
/* ------------------------ * ExecEndGroup(node) * * ----------------------- */ void ExecEndGroup(GroupState *node) { PlanState *outerPlan; ExecFreeExprContext(&node->ss.ps); /* clean up tuple table */ ExecClearTuple(node->ss.ss_ScanTupleSlot); outerPlan = outerPlanState(node); ExecEndNode(outerPlan); }
/* ---------------------------------------------------------------- * ExecEndBitmapHeapScan * ---------------------------------------------------------------- */ void ExecEndBitmapHeapScan(BitmapHeapScanState *node) { HeapScanDesc scanDesc; /* * extract information from the node */ scanDesc = node->ss.ss_currentScanDesc; /* * Free the exprcontext */ ExecFreeExprContext(&node->ss.ps); /* * clear out tuple table slots */ if (node->ss.ps.ps_ResultTupleSlot) ExecClearTuple(node->ss.ps.ps_ResultTupleSlot); ExecClearTuple(node->ss.ss_ScanTupleSlot); /* * close down subplans */ ExecEndNode(outerPlanState(node)); /* * release bitmaps and buffers if any */ if (node->tbmiterator) tbm_end_iterate(node->tbmiterator); if (node->prefetch_iterator) tbm_end_iterate(node->prefetch_iterator); if (node->tbm) tbm_free(node->tbm); if (node->shared_tbmiterator) tbm_end_shared_iterate(node->shared_tbmiterator); if (node->shared_prefetch_iterator) tbm_end_shared_iterate(node->shared_prefetch_iterator); if (node->vmbuffer != InvalidBuffer) ReleaseBuffer(node->vmbuffer); if (node->pvmbuffer != InvalidBuffer) ReleaseBuffer(node->pvmbuffer); /* * close heap scan */ heap_endscan(scanDesc); }
/* ---------------------------------------------------------------- * ExecEndWorkTableScan * * frees any storage allocated through C routines. * ---------------------------------------------------------------- */ void ExecEndWorkTableScan(WorkTableScanState *node) { /* * Free exprcontext */ ExecFreeExprContext(&node->ss.ps); /* * clean out the tuple table */ ExecClearTuple(node->ss.ps.ps_ResultTupleSlot); ExecClearTuple(node->ss.ss_ScanTupleSlot); }
void ExecEndRepeat(RepeatState *node) { /* Free the ExprContext */ ExecFreeExprContext(&node->ps); /* Clean out the tuple table */ ExecClearTuple(node->ps.ps_ResultTupleSlot); /* End the subplans */ ExecEndNode(outerPlanState(node)); EndPlanStateGpmonPkt(&node->ps); }
/* ---------------------------------------------------------------- * ExecEndIndexOnlyScan * ---------------------------------------------------------------- */ void ExecEndIndexOnlyScan(IndexOnlyScanState *node) { Relation indexRelationDesc; IndexScanDesc indexScanDesc; Relation relation; /* * extract information from the node */ indexRelationDesc = node->ioss_RelationDesc; indexScanDesc = node->ioss_ScanDesc; relation = node->ss.ss_currentRelation; /* Release VM buffer pin, if any. */ if (node->ioss_VMBuffer != InvalidBuffer) { ReleaseBuffer(node->ioss_VMBuffer); node->ioss_VMBuffer = InvalidBuffer; } /* * Free the exprcontext(s) ... now dead code, see ExecFreeExprContext */ #ifdef NOT_USED ExecFreeExprContext(&node->ss.ps); if (node->ioss_RuntimeContext) FreeExprContext(node->ioss_RuntimeContext, true); #endif /* * clear out tuple table slots */ ExecClearTuple(node->ss.ps.ps_ResultTupleSlot); ExecClearTuple(node->ss.ss_ScanTupleSlot); /* * close the index relation (no-op if we didn't open it) */ if (indexScanDesc) index_endscan(indexScanDesc); if (indexRelationDesc) index_close(indexRelationDesc, NoLock); /* * close the heap relation. */ ExecCloseScanRelation(relation); }
/* ---------------------------------------------------------------- * ExecEndForeignScan * * frees any storage allocated through C routines. * ---------------------------------------------------------------- */ void ExecEndForeignScan(ForeignScanState *node) { /* Let the FDW shut down */ node->fdwroutine->EndForeignScan(node); /* Free the exprcontext */ ExecFreeExprContext(&node->ss.ps); /* clean out the tuple table */ ExecClearTuple(node->ss.ps.ps_ResultTupleSlot); ExecClearTuple(node->ss.ss_ScanTupleSlot); /* close the relation. */ ExecCloseScanRelation(node->ss.ss_currentRelation); }
/* --------------------------------------------------------------- * ExecEndHash * * clean up routine for Hash node * ---------------------------------------------------------------- */ void ExecEndHash(HashState *node) { PlanState *outerPlan; /* * free exprcontext */ ExecFreeExprContext(&node->ps); /* * shut down the subplan */ outerPlan = outerPlanState(node); ExecEndNode(outerPlan); }
void ExecEndCustomScan(CustomScanState *node) { Assert(node->methods->EndCustomScan != NULL); node->methods->EndCustomScan(node); /* Free the exprcontext */ ExecFreeExprContext(&node->ss.ps); /* Clean out the tuple table */ ExecClearTuple(node->ss.ps.ps_ResultTupleSlot); ExecClearTuple(node->ss.ss_ScanTupleSlot); /* Close the heap relation */ if (node->ss.ss_currentRelation) ExecCloseScanRelation(node->ss.ss_currentRelation); }
/* ---------------------------------------------------------------- * ExecEndResult * * frees up storage allocated through C routines * ---------------------------------------------------------------- */ void ExecEndResult(ResultState *node) { /* * Free the exprcontext */ ExecFreeExprContext(&node->ps); /* * clean out the tuple table */ ExecClearTuple(node->ps.ps_ResultTupleSlot); /* * shut down subplans */ ExecEndNode(outerPlanState(node)); }
/* ---------------------------------------------------------------- * ExecEndIndexScan * ---------------------------------------------------------------- */ void ExecEndIndexScan(IndexScanState *node) { Relation indexRelationDesc; IndexScanDesc indexScanDesc; Relation relation; /* * extract information from the node */ indexRelationDesc = node->iss_RelationDesc; indexScanDesc = node->iss_ScanDesc; relation = node->ss.ss_currentRelation; /* * Free the exprcontext(s) ... now dead code, see ExecFreeExprContext */ #ifdef NOT_USED ExecFreeExprContext(&node->ss.ps); if (node->iss_RuntimeContext) FreeExprContext(node->iss_RuntimeContext); #endif /* * clear out tuple table slots */ ExecClearTuple(node->ss.ps.ps_ResultTupleSlot); ExecClearTuple(node->ss.ss_ScanTupleSlot); /* * close the index relation (no-op if we didn't open it) */ ExecEagerFreeIndexScan(node); if (indexRelationDesc) index_close(indexRelationDesc, NoLock); /* * close the heap relation. */ ExecCloseScanRelation(relation); FreeRuntimeKeysContext(node); EndPlanStateGpmonPkt(&node->ss.ps); }
/* ---------------------------------------------------------------- * ExecEndSubqueryScan * * frees any storage allocated through C routines. * ---------------------------------------------------------------- */ void ExecEndSubqueryScan(SubqueryScanState *node) { /* * Free the exprcontext */ ExecFreeExprContext(&node->ss.ps); /* * clean out the upper tuple table */ ExecClearTuple(node->ss.ps.ps_ResultTupleSlot); ExecClearTuple(node->ss.ss_ScanTupleSlot); /* * close down subquery */ ExecEndNode(node->subplan); }
/* ---------------------------------------------------------------- * ExecEndCteScan * * frees any storage allocated through C routines. * ---------------------------------------------------------------- */ void ExecEndCteScan(CteScanState *node) { /* * Free exprcontext */ ExecFreeExprContext(&node->ss.ps); /* * clean out the tuple table */ ExecClearTuple(node->ss.ps.ps_ResultTupleSlot); ExecClearTuple(node->ss.ss_ScanTupleSlot); /* * If I am the leader, free the tuplestore. */ if (node->leader == node) tuplestore_end(node->cte_table); }
/* ---------------------------------------------------------------- * ExecEndFunctionScan * * frees any storage allocated through C routines. * ---------------------------------------------------------------- */ void ExecEndFunctionScan(FunctionScanState *node) { /* * Free the exprcontext */ ExecFreeExprContext(&node->ss.ps); /* * clean out the tuple table */ ExecClearTuple(node->ss.ps.ps_ResultTupleSlot); ExecClearTuple(node->ss.ss_ScanTupleSlot); /* * Release tuplestore resources */ if (node->tuplestorestate != NULL) tuplestore_end(node->tuplestorestate); node->tuplestorestate = NULL; }