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

Generated by: LCOV version 1.13