@@ -664,63 +664,37 @@ static Plan *
664
664
create_append_plan (PlannerInfo * root , AppendPath * best_path )
665
665
{
666
666
Append * plan ;
667
- RelOptInfo * rel = best_path -> path .parent ;
668
- List * tlist = build_relation_tlist (rel );
667
+ List * tlist = build_relation_tlist (best_path -> path .parent );
669
668
List * subplans = NIL ;
670
669
ListCell * subpaths ;
671
670
672
671
/*
673
- * The subpaths list could be empty, if every child was proven empty by
674
- * constraint exclusion. In that case generate a dummy plan that returns
675
- * no rows.
672
+ * It is possible for the subplans list to contain only one entry, or even
673
+ * no entries. Handle these cases specially.
676
674
*
677
- * Note that an AppendPath with no members is also generated in certain
678
- * cases where there was no appending construct at all, but we know the
679
- * relation is empty (see set_dummy_rel_pathlist).
675
+ * XXX ideally, if there's just one entry, we'd not bother to generate an
676
+ * Append node but just return the single child. At the moment this does
677
+ * not work because the varno of the child scan plan won't match the
678
+ * parent-rel Vars it'll be asked to emit.
680
679
*/
681
680
if (best_path -> subpaths == NIL )
682
681
{
683
- /*
684
- * If this is a dummy path for a subquery, we have to wrap the
685
- * subquery's original plan in a SubqueryScan so that setrefs.c will
686
- * do the right things. (In particular, it must pull up the
687
- * subquery's rangetable so that the executor will apply permissions
688
- * checks to those rels at runtime.)
689
- */
690
- if (rel -> rtekind == RTE_SUBQUERY )
691
- {
692
- Assert (is_dummy_plan (rel -> subplan ));
693
- return (Plan * ) make_subqueryscan (tlist ,
694
- NIL ,
695
- rel -> relid ,
696
- rel -> subplan );
697
- }
698
- else
699
- {
700
- /* Generate a Result plan with constant-FALSE gating qual */
701
- return (Plan * ) make_result (root ,
702
- tlist ,
703
- (Node * ) list_make1 (makeBoolConst (false,
704
- false)),
705
- NULL );
706
- }
682
+ /* Generate a Result plan with constant-FALSE gating qual */
683
+ return (Plan * ) make_result (root ,
684
+ tlist ,
685
+ (Node * ) list_make1 (makeBoolConst (false,
686
+ false)),
687
+ NULL );
707
688
}
708
689
709
- /* Build the plan for each child */
690
+ /* Normal case with multiple subpaths */
710
691
foreach (subpaths , best_path -> subpaths )
711
692
{
712
693
Path * subpath = (Path * ) lfirst (subpaths );
713
694
714
695
subplans = lappend (subplans , create_plan_recurse (root , subpath ));
715
696
}
716
697
717
- /*
718
- * XXX ideally, if there's just one child, we'd not bother to generate an
719
- * Append node but just return the single child. At the moment this does
720
- * not work because the varno of the child scan plan won't match the
721
- * parent-rel Vars it'll be asked to emit.
722
- */
723
-
724
698
plan = make_append (subplans , tlist );
725
699
726
700
return (Plan * ) plan ;
0 commit comments