@@ -271,16 +271,20 @@ ExecReScan(PlanState *node)
271271 * ExecMarkPos
272272 *
273273 * Marks the current scan position.
274+ *
275+ * NOTE: mark/restore capability is currently needed only for plan nodes
276+ * that are the immediate inner child of a MergeJoin node. Since MergeJoin
277+ * requires sorted input, there is never any need to support mark/restore in
278+ * node types that cannot produce sorted output. There are some cases in
279+ * which a node can pass through sorted data from its child; if we don't
280+ * implement mark/restore for such a node type, the planner compensates by
281+ * inserting a Material node above that node.
274282 */
275283void
276284ExecMarkPos (PlanState * node )
277285{
278286 switch (nodeTag (node ))
279287 {
280- case T_SeqScanState :
281- ExecSeqMarkPos ((SeqScanState * ) node );
282- break ;
283-
284288 case T_IndexScanState :
285289 ExecIndexMarkPos ((IndexScanState * ) node );
286290 break ;
@@ -289,14 +293,6 @@ ExecMarkPos(PlanState *node)
289293 ExecIndexOnlyMarkPos ((IndexOnlyScanState * ) node );
290294 break ;
291295
292- case T_TidScanState :
293- ExecTidMarkPos ((TidScanState * ) node );
294- break ;
295-
296- case T_ValuesScanState :
297- ExecValuesMarkPos ((ValuesScanState * ) node );
298- break ;
299-
300296 case T_CustomScanState :
301297 ExecCustomMarkPos ((CustomScanState * ) node );
302298 break ;
@@ -338,10 +334,6 @@ ExecRestrPos(PlanState *node)
338334{
339335 switch (nodeTag (node ))
340336 {
341- case T_SeqScanState :
342- ExecSeqRestrPos ((SeqScanState * ) node );
343- break ;
344-
345337 case T_IndexScanState :
346338 ExecIndexRestrPos ((IndexScanState * ) node );
347339 break ;
@@ -350,14 +342,6 @@ ExecRestrPos(PlanState *node)
350342 ExecIndexOnlyRestrPos ((IndexOnlyScanState * ) node );
351343 break ;
352344
353- case T_TidScanState :
354- ExecTidRestrPos ((TidScanState * ) node );
355- break ;
356-
357- case T_ValuesScanState :
358- ExecValuesRestrPos ((ValuesScanState * ) node );
359- break ;
360-
361345 case T_CustomScanState :
362346 ExecCustomRestrPos ((CustomScanState * ) node );
363347 break ;
@@ -386,14 +370,6 @@ ExecRestrPos(PlanState *node)
386370 * This is used during planning and so must accept a Path, not a Plan.
387371 * We keep it here to be adjacent to the routines above, which also must
388372 * know which plan types support mark/restore.
389- *
390- * XXX Ideally, all plan node types would support mark/restore, and this
391- * wouldn't be needed. For now, this had better match the routines above.
392- *
393- * (However, since the only present use of mark/restore is in mergejoin,
394- * there is no need to support mark/restore in any plan type that is not
395- * capable of generating ordered output. So the seqscan, tidscan,
396- * and valuesscan support is actually useless code at present.)
397373 */
398374bool
399375ExecSupportsMarkRestore (Path * pathnode )
@@ -405,11 +381,8 @@ ExecSupportsMarkRestore(Path *pathnode)
405381 */
406382 switch (pathnode -> pathtype )
407383 {
408- case T_SeqScan :
409384 case T_IndexScan :
410385 case T_IndexOnlyScan :
411- case T_TidScan :
412- case T_ValuesScan :
413386 case T_Material :
414387 case T_Sort :
415388 return true;
@@ -426,7 +399,11 @@ ExecSupportsMarkRestore(Path *pathnode)
426399 * Although Result supports mark/restore if it has a child plan
427400 * that does, we presently come here only for ResultPath nodes,
428401 * which represent Result plans without a child plan. So there is
429- * nothing to recurse to and we can just say "false".
402+ * nothing to recurse to and we can just say "false". (This means
403+ * that Result's support for mark/restore is in fact dead code.
404+ * We keep it since it's not much code, and someday the planner
405+ * might be smart enough to use it. That would require making
406+ * this function smarter too, of course.)
430407 */
431408 Assert (IsA (pathnode , ResultPath ));
432409 return false;
0 commit comments