@@ -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{
278286switch (nodeTag (node ))
279287{
280- case T_SeqScanState :
281- ExecSeqMarkPos ((SeqScanState * )node );
282- break ;
283-
284288case T_IndexScanState :
285289ExecIndexMarkPos ((IndexScanState * )node );
286290break ;
@@ -289,14 +293,6 @@ ExecMarkPos(PlanState *node)
289293ExecIndexOnlyMarkPos ((IndexOnlyScanState * )node );
290294break ;
291295
292- case T_TidScanState :
293- ExecTidMarkPos ((TidScanState * )node );
294- break ;
295-
296- case T_ValuesScanState :
297- ExecValuesMarkPos ((ValuesScanState * )node );
298- break ;
299-
300296case T_CustomScanState :
301297ExecCustomMarkPos ((CustomScanState * )node );
302298break ;
@@ -338,10 +334,6 @@ ExecRestrPos(PlanState *node)
338334{
339335switch (nodeTag (node ))
340336{
341- case T_SeqScanState :
342- ExecSeqRestrPos ((SeqScanState * )node );
343- break ;
344-
345337case T_IndexScanState :
346338ExecIndexRestrPos ((IndexScanState * )node );
347339break ;
@@ -350,14 +342,6 @@ ExecRestrPos(PlanState *node)
350342ExecIndexOnlyRestrPos ((IndexOnlyScanState * )node );
351343break ;
352344
353- case T_TidScanState :
354- ExecTidRestrPos ((TidScanState * )node );
355- break ;
356-
357- case T_ValuesScanState :
358- ExecValuesRestrPos ((ValuesScanState * )node );
359- break ;
360-
361345case T_CustomScanState :
362346ExecCustomRestrPos ((CustomScanState * )node );
363347break ;
@@ -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 */
406382switch (pathnode -> pathtype )
407383{
408- case T_SeqScan :
409384case T_IndexScan :
410385case T_IndexOnlyScan :
411- case T_TidScan :
412- case T_ValuesScan :
413386case T_Material :
414387case T_Sort :
415388return 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 */
431408Assert (IsA (pathnode ,ResultPath ));
432409return false;