LCOV - code coverage report
Current view: top level - src/backend/executor - execAmi.c (source / functions) Hit Total Coverage
Test: PostgreSQL 13devel Lines: 152 203 74.9 %
Date: 2019-11-22 06:06:53 Functions: 7 7 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*-------------------------------------------------------------------------
       2             :  *
       3             :  * execAmi.c
       4             :  *    miscellaneous executor access method routines
       5             :  *
       6             :  * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
       7             :  * Portions Copyright (c) 1994, Regents of the University of California
       8             :  *
       9             :  *  src/backend/executor/execAmi.c
      10             :  *
      11             :  *-------------------------------------------------------------------------
      12             :  */
      13             : #include "postgres.h"
      14             : 
      15             : #include "access/amapi.h"
      16             : #include "access/htup_details.h"
      17             : #include "executor/execdebug.h"
      18             : #include "executor/nodeAgg.h"
      19             : #include "executor/nodeAppend.h"
      20             : #include "executor/nodeBitmapAnd.h"
      21             : #include "executor/nodeBitmapHeapscan.h"
      22             : #include "executor/nodeBitmapIndexscan.h"
      23             : #include "executor/nodeBitmapOr.h"
      24             : #include "executor/nodeCtescan.h"
      25             : #include "executor/nodeCustom.h"
      26             : #include "executor/nodeForeignscan.h"
      27             : #include "executor/nodeFunctionscan.h"
      28             : #include "executor/nodeGather.h"
      29             : #include "executor/nodeGatherMerge.h"
      30             : #include "executor/nodeGroup.h"
      31             : #include "executor/nodeHash.h"
      32             : #include "executor/nodeHashjoin.h"
      33             : #include "executor/nodeIndexonlyscan.h"
      34             : #include "executor/nodeIndexscan.h"
      35             : #include "executor/nodeLimit.h"
      36             : #include "executor/nodeLockRows.h"
      37             : #include "executor/nodeMaterial.h"
      38             : #include "executor/nodeMergeAppend.h"
      39             : #include "executor/nodeMergejoin.h"
      40             : #include "executor/nodeModifyTable.h"
      41             : #include "executor/nodeNamedtuplestorescan.h"
      42             : #include "executor/nodeNestloop.h"
      43             : #include "executor/nodeProjectSet.h"
      44             : #include "executor/nodeRecursiveunion.h"
      45             : #include "executor/nodeResult.h"
      46             : #include "executor/nodeSamplescan.h"
      47             : #include "executor/nodeSeqscan.h"
      48             : #include "executor/nodeSetOp.h"
      49             : #include "executor/nodeSort.h"
      50             : #include "executor/nodeSubplan.h"
      51             : #include "executor/nodeSubqueryscan.h"
      52             : #include "executor/nodeTableFuncscan.h"
      53             : #include "executor/nodeTidscan.h"
      54             : #include "executor/nodeUnique.h"
      55             : #include "executor/nodeValuesscan.h"
      56             : #include "executor/nodeWindowAgg.h"
      57             : #include "executor/nodeWorktablescan.h"
      58             : #include "nodes/extensible.h"
      59             : #include "nodes/nodeFuncs.h"
      60             : #include "nodes/pathnodes.h"
      61             : #include "utils/rel.h"
      62             : #include "utils/syscache.h"
      63             : 
      64             : static bool IndexSupportsBackwardScan(Oid indexid);
      65             : 
      66             : 
      67             : /*
      68             :  * ExecReScan
      69             :  *      Reset a plan node so that its output can be re-scanned.
      70             :  *
      71             :  * Note that if the plan node has parameters that have changed value,
      72             :  * the output might be different from last time.
      73             :  */
      74             : void
      75     5822258 : ExecReScan(PlanState *node)
      76             : {
      77             :     /* If collecting timing stats, update them */
      78     5822258 :     if (node->instrument)
      79        2504 :         InstrEndLoop(node->instrument);
      80             : 
      81             :     /*
      82             :      * If we have changed parameters, propagate that info.
      83             :      *
      84             :      * Note: ExecReScanSetParamPlan() can add bits to node->chgParam,
      85             :      * corresponding to the output param(s) that the InitPlan will update.
      86             :      * Since we make only one pass over the list, that means that an InitPlan
      87             :      * can depend on the output param(s) of a sibling InitPlan only if that
      88             :      * sibling appears earlier in the list.  This is workable for now given
      89             :      * the limited ways in which one InitPlan could depend on another, but
      90             :      * eventually we might need to work harder (or else make the planner
      91             :      * enlarge the extParam/allParam sets to include the params of depended-on
      92             :      * InitPlans).
      93             :      */
      94     5822258 :     if (node->chgParam != NULL)
      95             :     {
      96             :         ListCell   *l;
      97             : 
      98     5057864 :         foreach(l, node->initPlan)
      99             :         {
     100         730 :             SubPlanState *sstate = (SubPlanState *) lfirst(l);
     101         730 :             PlanState  *splan = sstate->planstate;
     102             : 
     103         730 :             if (splan->plan->extParam != NULL)    /* don't care about child
     104             :                                                  * local Params */
     105         632 :                 UpdateChangedParamSet(splan, node->chgParam);
     106         730 :             if (splan->chgParam != NULL)
     107         472 :                 ExecReScanSetParamPlan(sstate, node);
     108             :         }
     109     5138074 :         foreach(l, node->subPlan)
     110             :         {
     111       80940 :             SubPlanState *sstate = (SubPlanState *) lfirst(l);
     112       80940 :             PlanState  *splan = sstate->planstate;
     113             : 
     114       80940 :             if (splan->plan->extParam != NULL)
     115       80928 :                 UpdateChangedParamSet(splan, node->chgParam);
     116             :         }
     117             :         /* Well. Now set chgParam for left/right trees. */
     118     5057134 :         if (node->lefttree != NULL)
     119     2565904 :             UpdateChangedParamSet(node->lefttree, node->chgParam);
     120     5057134 :         if (node->righttree != NULL)
     121     1093496 :             UpdateChangedParamSet(node->righttree, node->chgParam);
     122             :     }
     123             : 
     124             :     /* Call expression callbacks */
     125     5822258 :     if (node->ps_ExprContext)
     126     5066814 :         ReScanExprContext(node->ps_ExprContext);
     127             : 
     128             :     /* And do node-type-specific processing */
     129     5822258 :     switch (nodeTag(node))
     130             :     {
     131             :         case T_ResultState:
     132       83314 :             ExecReScanResult((ResultState *) node);
     133       83314 :             break;
     134             : 
     135             :         case T_ProjectSetState:
     136       39446 :             ExecReScanProjectSet((ProjectSetState *) node);
     137       39446 :             break;
     138             : 
     139             :         case T_ModifyTableState:
     140           0 :             ExecReScanModifyTable((ModifyTableState *) node);
     141           0 :             break;
     142             : 
     143             :         case T_AppendState:
     144       42038 :             ExecReScanAppend((AppendState *) node);
     145       42038 :             break;
     146             : 
     147             :         case T_MergeAppendState:
     148          12 :             ExecReScanMergeAppend((MergeAppendState *) node);
     149          12 :             break;
     150             : 
     151             :         case T_RecursiveUnionState:
     152           0 :             ExecReScanRecursiveUnion((RecursiveUnionState *) node);
     153           0 :             break;
     154             : 
     155             :         case T_BitmapAndState:
     156          28 :             ExecReScanBitmapAnd((BitmapAndState *) node);
     157          28 :             break;
     158             : 
     159             :         case T_BitmapOrState:
     160           0 :             ExecReScanBitmapOr((BitmapOrState *) node);
     161           0 :             break;
     162             : 
     163             :         case T_SeqScanState:
     164      836812 :             ExecReScanSeqScan((SeqScanState *) node);
     165      836812 :             break;
     166             : 
     167             :         case T_SampleScanState:
     168          50 :             ExecReScanSampleScan((SampleScanState *) node);
     169          50 :             break;
     170             : 
     171             :         case T_GatherState:
     172         200 :             ExecReScanGather((GatherState *) node);
     173         200 :             break;
     174             : 
     175             :         case T_GatherMergeState:
     176          24 :             ExecReScanGatherMerge((GatherMergeState *) node);
     177          24 :             break;
     178             : 
     179             :         case T_IndexScanState:
     180      206652 :             ExecReScanIndexScan((IndexScanState *) node);
     181      206648 :             break;
     182             : 
     183             :         case T_IndexOnlyScanState:
     184        8800 :             ExecReScanIndexOnlyScan((IndexOnlyScanState *) node);
     185        8800 :             break;
     186             : 
     187             :         case T_BitmapIndexScanState:
     188        2936 :             ExecReScanBitmapIndexScan((BitmapIndexScanState *) node);
     189        2936 :             break;
     190             : 
     191             :         case T_BitmapHeapScanState:
     192        2480 :             ExecReScanBitmapHeapScan((BitmapHeapScanState *) node);
     193        2480 :             break;
     194             : 
     195             :         case T_TidScanState:
     196          12 :             ExecReScanTidScan((TidScanState *) node);
     197          12 :             break;
     198             : 
     199             :         case T_SubqueryScanState:
     200         262 :             ExecReScanSubqueryScan((SubqueryScanState *) node);
     201         262 :             break;
     202             : 
     203             :         case T_FunctionScanState:
     204     1373692 :             ExecReScanFunctionScan((FunctionScanState *) node);
     205     1373692 :             break;
     206             : 
     207             :         case T_TableFuncScanState:
     208         128 :             ExecReScanTableFuncScan((TableFuncScanState *) node);
     209         128 :             break;
     210             : 
     211             :         case T_ValuesScanState:
     212       40138 :             ExecReScanValuesScan((ValuesScanState *) node);
     213       40138 :             break;
     214             : 
     215             :         case T_CteScanState:
     216         322 :             ExecReScanCteScan((CteScanState *) node);
     217         322 :             break;
     218             : 
     219             :         case T_NamedTuplestoreScanState:
     220           0 :             ExecReScanNamedTuplestoreScan((NamedTuplestoreScanState *) node);
     221           0 :             break;
     222             : 
     223             :         case T_WorkTableScanState:
     224        3712 :             ExecReScanWorkTableScan((WorkTableScanState *) node);
     225        3712 :             break;
     226             : 
     227             :         case T_ForeignScanState:
     228         726 :             ExecReScanForeignScan((ForeignScanState *) node);
     229         726 :             break;
     230             : 
     231             :         case T_CustomScanState:
     232           0 :             ExecReScanCustomScan((CustomScanState *) node);
     233           0 :             break;
     234             : 
     235             :         case T_NestLoopState:
     236       41340 :             ExecReScanNestLoop((NestLoopState *) node);
     237       41340 :             break;
     238             : 
     239             :         case T_MergeJoinState:
     240          40 :             ExecReScanMergeJoin((MergeJoinState *) node);
     241          40 :             break;
     242             : 
     243             :         case T_HashJoinState:
     244     1052738 :             ExecReScanHashJoin((HashJoinState *) node);
     245     1052738 :             break;
     246             : 
     247             :         case T_MaterialState:
     248      692428 :             ExecReScanMaterial((MaterialState *) node);
     249      692428 :             break;
     250             : 
     251             :         case T_SortState:
     252       20162 :             ExecReScanSort((SortState *) node);
     253       20162 :             break;
     254             : 
     255             :         case T_GroupState:
     256          12 :             ExecReScanGroup((GroupState *) node);
     257          12 :             break;
     258             : 
     259             :         case T_AggState:
     260     1131760 :             ExecReScanAgg((AggState *) node);
     261     1131760 :             break;
     262             : 
     263             :         case T_WindowAggState:
     264          52 :             ExecReScanWindowAgg((WindowAggState *) node);
     265          52 :             break;
     266             : 
     267             :         case T_UniqueState:
     268           0 :             ExecReScanUnique((UniqueState *) node);
     269           0 :             break;
     270             : 
     271             :         case T_HashState:
     272      241450 :             ExecReScanHash((HashState *) node);
     273      241450 :             break;
     274             : 
     275             :         case T_SetOpState:
     276           0 :             ExecReScanSetOp((SetOpState *) node);
     277           0 :             break;
     278             : 
     279             :         case T_LockRowsState:
     280          16 :             ExecReScanLockRows((LockRowsState *) node);
     281          16 :             break;
     282             : 
     283             :         case T_LimitState:
     284         476 :             ExecReScanLimit((LimitState *) node);
     285         476 :             break;
     286             : 
     287             :         default:
     288           0 :             elog(ERROR, "unrecognized node type: %d", (int) nodeTag(node));
     289             :             break;
     290             :     }
     291             : 
     292     5822254 :     if (node->chgParam != NULL)
     293             :     {
     294     5057134 :         bms_free(node->chgParam);
     295     5057134 :         node->chgParam = NULL;
     296             :     }
     297     5822254 : }
     298             : 
     299             : /*
     300             :  * ExecMarkPos
     301             :  *
     302             :  * Marks the current scan position.
     303             :  *
     304             :  * NOTE: mark/restore capability is currently needed only for plan nodes
     305             :  * that are the immediate inner child of a MergeJoin node.  Since MergeJoin
     306             :  * requires sorted input, there is never any need to support mark/restore in
     307             :  * node types that cannot produce sorted output.  There are some cases in
     308             :  * which a node can pass through sorted data from its child; if we don't
     309             :  * implement mark/restore for such a node type, the planner compensates by
     310             :  * inserting a Material node above that node.
     311             :  */
     312             : void
     313      436788 : ExecMarkPos(PlanState *node)
     314             : {
     315      436788 :     switch (nodeTag(node))
     316             :     {
     317             :         case T_IndexScanState:
     318        4026 :             ExecIndexMarkPos((IndexScanState *) node);
     319        4026 :             break;
     320             : 
     321             :         case T_IndexOnlyScanState:
     322       84004 :             ExecIndexOnlyMarkPos((IndexOnlyScanState *) node);
     323       84004 :             break;
     324             : 
     325             :         case T_CustomScanState:
     326           0 :             ExecCustomMarkPos((CustomScanState *) node);
     327           0 :             break;
     328             : 
     329             :         case T_MaterialState:
     330        4240 :             ExecMaterialMarkPos((MaterialState *) node);
     331        4240 :             break;
     332             : 
     333             :         case T_SortState:
     334      344518 :             ExecSortMarkPos((SortState *) node);
     335      344518 :             break;
     336             : 
     337             :         case T_ResultState:
     338           0 :             ExecResultMarkPos((ResultState *) node);
     339           0 :             break;
     340             : 
     341             :         default:
     342             :             /* don't make hard error unless caller asks to restore... */
     343           0 :             elog(DEBUG2, "unrecognized node type: %d", (int) nodeTag(node));
     344           0 :             break;
     345             :     }
     346      436788 : }
     347             : 
     348             : /*
     349             :  * ExecRestrPos
     350             :  *
     351             :  * restores the scan position previously saved with ExecMarkPos()
     352             :  *
     353             :  * NOTE: the semantics of this are that the first ExecProcNode following
     354             :  * the restore operation will yield the same tuple as the first one following
     355             :  * the mark operation.  It is unspecified what happens to the plan node's
     356             :  * result TupleTableSlot.  (In most cases the result slot is unchanged by
     357             :  * a restore, but the node may choose to clear it or to load it with the
     358             :  * restored-to tuple.)  Hence the caller should discard any previously
     359             :  * returned TupleTableSlot after doing a restore.
     360             :  */
     361             : void
     362       87638 : ExecRestrPos(PlanState *node)
     363             : {
     364       87638 :     switch (nodeTag(node))
     365             :     {
     366             :         case T_IndexScanState:
     367       36004 :             ExecIndexRestrPos((IndexScanState *) node);
     368       36004 :             break;
     369             : 
     370             :         case T_IndexOnlyScanState:
     371           0 :             ExecIndexOnlyRestrPos((IndexOnlyScanState *) node);
     372           0 :             break;
     373             : 
     374             :         case T_CustomScanState:
     375           0 :             ExecCustomRestrPos((CustomScanState *) node);
     376           0 :             break;
     377             : 
     378             :         case T_MaterialState:
     379       36024 :             ExecMaterialRestrPos((MaterialState *) node);
     380       36024 :             break;
     381             : 
     382             :         case T_SortState:
     383       15610 :             ExecSortRestrPos((SortState *) node);
     384       15610 :             break;
     385             : 
     386             :         case T_ResultState:
     387           0 :             ExecResultRestrPos((ResultState *) node);
     388           0 :             break;
     389             : 
     390             :         default:
     391           0 :             elog(ERROR, "unrecognized node type: %d", (int) nodeTag(node));
     392             :             break;
     393             :     }
     394       87638 : }
     395             : 
     396             : /*
     397             :  * ExecSupportsMarkRestore - does a Path support mark/restore?
     398             :  *
     399             :  * This is used during planning and so must accept a Path, not a Plan.
     400             :  * We keep it here to be adjacent to the routines above, which also must
     401             :  * know which plan types support mark/restore.
     402             :  */
     403             : bool
     404        2946 : ExecSupportsMarkRestore(Path *pathnode)
     405             : {
     406             :     /*
     407             :      * For consistency with the routines above, we do not examine the nodeTag
     408             :      * but rather the pathtype, which is the Plan node type the Path would
     409             :      * produce.
     410             :      */
     411        2946 :     switch (pathnode->pathtype)
     412             :     {
     413             :         case T_IndexScan:
     414             :         case T_IndexOnlyScan:
     415             :         case T_Material:
     416             :         case T_Sort:
     417        2202 :             return true;
     418             : 
     419             :         case T_CustomScan:
     420             :             {
     421           0 :                 CustomPath *customPath = castNode(CustomPath, pathnode);
     422             : 
     423           0 :                 if (customPath->flags & CUSTOMPATH_SUPPORT_MARK_RESTORE)
     424           0 :                     return true;
     425           0 :                 return false;
     426             :             }
     427             :         case T_Result:
     428             : 
     429             :             /*
     430             :              * Result supports mark/restore iff it has a child plan that does.
     431             :              *
     432             :              * We have to be careful here because there is more than one Path
     433             :              * type that can produce a Result plan node.
     434             :              */
     435           0 :             if (IsA(pathnode, ProjectionPath))
     436           0 :                 return ExecSupportsMarkRestore(((ProjectionPath *) pathnode)->subpath);
     437           0 :             else if (IsA(pathnode, MinMaxAggPath))
     438           0 :                 return false;   /* childless Result */
     439           0 :             else if (IsA(pathnode, GroupResultPath))
     440           0 :                 return false;   /* childless Result */
     441             :             else
     442             :             {
     443             :                 /* Simple RTE_RESULT base relation */
     444             :                 Assert(IsA(pathnode, Path));
     445           0 :                 return false;   /* childless Result */
     446             :             }
     447             : 
     448             :         case T_Append:
     449             :             {
     450          72 :                 AppendPath *appendPath = castNode(AppendPath, pathnode);
     451             : 
     452             :                 /*
     453             :                  * If there's exactly one child, then there will be no Append
     454             :                  * in the final plan, so we can handle mark/restore if the
     455             :                  * child plan node can.
     456             :                  */
     457          72 :                 if (list_length(appendPath->subpaths) == 1)
     458           0 :                     return ExecSupportsMarkRestore((Path *) linitial(appendPath->subpaths));
     459             :                 /* Otherwise, Append can't handle it */
     460          72 :                 return false;
     461             :             }
     462             : 
     463             :         case T_MergeAppend:
     464             :             {
     465          28 :                 MergeAppendPath *mapath = castNode(MergeAppendPath, pathnode);
     466             : 
     467             :                 /*
     468             :                  * Like the Append case above, single-subpath MergeAppends
     469             :                  * won't be in the final plan, so just return the child's
     470             :                  * mark/restore ability.
     471             :                  */
     472          28 :                 if (list_length(mapath->subpaths) == 1)
     473           0 :                     return ExecSupportsMarkRestore((Path *) linitial(mapath->subpaths));
     474             :                 /* Otherwise, MergeAppend can't handle it */
     475          28 :                 return false;
     476             :             }
     477             : 
     478             :         default:
     479         644 :             break;
     480             :     }
     481             : 
     482         644 :     return false;
     483             : }
     484             : 
     485             : /*
     486             :  * ExecSupportsBackwardScan - does a plan type support backwards scanning?
     487             :  *
     488             :  * Ideally, all plan types would support backwards scan, but that seems
     489             :  * unlikely to happen soon.  In some cases, a plan node passes the backwards
     490             :  * scan down to its children, and so supports backwards scan only if its
     491             :  * children do.  Therefore, this routine must be passed a complete plan tree.
     492             :  */
     493             : bool
     494        3864 : ExecSupportsBackwardScan(Plan *node)
     495             : {
     496        3864 :     if (node == NULL)
     497           0 :         return false;
     498             : 
     499             :     /*
     500             :      * Parallel-aware nodes return a subset of the tuples in each worker, and
     501             :      * in general we can't expect to have enough bookkeeping state to know
     502             :      * which ones we returned in this worker as opposed to some other worker.
     503             :      */
     504        3864 :     if (node->parallel_aware)
     505           0 :         return false;
     506             : 
     507        3864 :     switch (nodeTag(node))
     508             :     {
     509             :         case T_Result:
     510         300 :             if (outerPlan(node) != NULL)
     511           0 :                 return ExecSupportsBackwardScan(outerPlan(node));
     512             :             else
     513         300 :                 return false;
     514             : 
     515             :         case T_Append:
     516             :             {
     517             :                 ListCell   *l;
     518             : 
     519          76 :                 foreach(l, ((Append *) node)->appendplans)
     520             :                 {
     521          56 :                     if (!ExecSupportsBackwardScan((Plan *) lfirst(l)))
     522           2 :                         return false;
     523             :                 }
     524             :                 /* need not check tlist because Append doesn't evaluate it */
     525          20 :                 return true;
     526             :             }
     527             : 
     528             :         case T_SampleScan:
     529             :             /* Simplify life for tablesample methods by disallowing this */
     530           4 :             return false;
     531             : 
     532             :         case T_Gather:
     533           0 :             return false;
     534             : 
     535             :         case T_IndexScan:
     536         330 :             return IndexSupportsBackwardScan(((IndexScan *) node)->indexid);
     537             : 
     538             :         case T_IndexOnlyScan:
     539          82 :             return IndexSupportsBackwardScan(((IndexOnlyScan *) node)->indexid);
     540             : 
     541             :         case T_SubqueryScan:
     542           0 :             return ExecSupportsBackwardScan(((SubqueryScan *) node)->subplan);
     543             : 
     544             :         case T_CustomScan:
     545             :             {
     546           0 :                 uint32      flags = ((CustomScan *) node)->flags;
     547             : 
     548           0 :                 if (flags & CUSTOMPATH_SUPPORT_BACKWARD_SCAN)
     549           0 :                     return true;
     550             :             }
     551           0 :             return false;
     552             : 
     553             :         case T_SeqScan:
     554             :         case T_TidScan:
     555             :         case T_FunctionScan:
     556             :         case T_ValuesScan:
     557             :         case T_CteScan:
     558             :         case T_Material:
     559             :         case T_Sort:
     560        2018 :             return true;
     561             : 
     562             :         case T_LockRows:
     563             :         case T_Limit:
     564          90 :             return ExecSupportsBackwardScan(outerPlan(node));
     565             : 
     566             :         default:
     567        1018 :             return false;
     568             :     }
     569             : }
     570             : 
     571             : /*
     572             :  * An IndexScan or IndexOnlyScan node supports backward scan only if the
     573             :  * index's AM does.
     574             :  */
     575             : static bool
     576         412 : IndexSupportsBackwardScan(Oid indexid)
     577             : {
     578             :     bool        result;
     579             :     HeapTuple   ht_idxrel;
     580             :     Form_pg_class idxrelrec;
     581             :     IndexAmRoutine *amroutine;
     582             : 
     583             :     /* Fetch the pg_class tuple of the index relation */
     584         412 :     ht_idxrel = SearchSysCache1(RELOID, ObjectIdGetDatum(indexid));
     585         412 :     if (!HeapTupleIsValid(ht_idxrel))
     586           0 :         elog(ERROR, "cache lookup failed for relation %u", indexid);
     587         412 :     idxrelrec = (Form_pg_class) GETSTRUCT(ht_idxrel);
     588             : 
     589             :     /* Fetch the index AM's API struct */
     590         412 :     amroutine = GetIndexAmRoutineByAmId(idxrelrec->relam, false);
     591             : 
     592         412 :     result = amroutine->amcanbackward;
     593             : 
     594         412 :     pfree(amroutine);
     595         412 :     ReleaseSysCache(ht_idxrel);
     596             : 
     597         412 :     return result;
     598             : }
     599             : 
     600             : /*
     601             :  * ExecMaterializesOutput - does a plan type materialize its output?
     602             :  *
     603             :  * Returns true if the plan node type is one that automatically materializes
     604             :  * its output (typically by keeping it in a tuplestore).  For such plans,
     605             :  * a rescan without any parameter change will have zero startup cost and
     606             :  * very low per-tuple cost.
     607             :  */
     608             : bool
     609      236048 : ExecMaterializesOutput(NodeTag plantype)
     610             : {
     611      236048 :     switch (plantype)
     612             :     {
     613             :         case T_Material:
     614             :         case T_FunctionScan:
     615             :         case T_TableFuncScan:
     616             :         case T_CteScan:
     617             :         case T_NamedTuplestoreScan:
     618             :         case T_WorkTableScan:
     619             :         case T_Sort:
     620        9924 :             return true;
     621             : 
     622             :         default:
     623      226124 :             break;
     624             :     }
     625             : 
     626      226124 :     return false;
     627             : }

Generated by: LCOV version 1.13