]> granicus.if.org Git - postgresql/blobdiff - src/backend/executor/nodeAppend.c
Make some small planner API cleanups.
[postgresql] / src / backend / executor / nodeAppend.c
index e7188b2d310698e403ae9a689eb1f7aedc4cf775..f3be2429dbeb122d186e941d26b2094982441bdc 100644 (file)
@@ -3,7 +3,7 @@
  * nodeAppend.c
  *       routines to handle append nodes.
  *
- * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  *
@@ -112,12 +112,6 @@ ExecInitAppend(Append *node, EState *estate, int eflags)
        /* check for unsupported flags */
        Assert(!(eflags & EXEC_FLAG_MARK));
 
-       /*
-        * Lock the non-leaf tables in the partition tree controlled by this node.
-        * It's a no-op for non-partitioned parent tables.
-        */
-       ExecLockNonLeafAppendTables(node->partitioned_rels, estate);
-
        /*
         * create new AppendState for our append node
         */
@@ -129,7 +123,7 @@ ExecInitAppend(Append *node, EState *estate, int eflags)
        appendstate->as_whichplan = INVALID_SUBPLAN_INDEX;
 
        /* If run-time partition pruning is enabled, then set that up now */
-       if (node->part_prune_infos != NIL)
+       if (node->part_prune_info != NULL)
        {
                PartitionPruneState *prunestate;
 
@@ -138,7 +132,7 @@ ExecInitAppend(Append *node, EState *estate, int eflags)
 
                /* Create the working data structure for pruning. */
                prunestate = ExecCreatePartitionPruneState(&appendstate->ps,
-                                                                                                  node->part_prune_infos);
+                                                                                                  node->part_prune_info);
                appendstate->as_prune_state = prunestate;
 
                /* Perform an initial partition prune, if required. */
@@ -151,7 +145,7 @@ ExecInitAppend(Append *node, EState *estate, int eflags)
                        /*
                         * The case where no subplans survive pruning must be handled
                         * specially.  The problem here is that code in explain.c requires
-                        * a MergeAppend to have at least one subplan in order for it to
+                        * aAppend to have at least one subplan in order for it to
                         * properly determine the Vars in that subplan's targetlist.  We
                         * sidestep this issue by just initializing the first subplan and
                         * setting as_whichplan to NO_MATCHING_SUBPLANS to indicate that
@@ -171,6 +165,7 @@ ExecInitAppend(Append *node, EState *estate, int eflags)
                {
                        /* We'll need to initialize all subplans */
                        nplans = list_length(node->appendplans);
+                       Assert(nplans > 0);
                        validsubplans = bms_add_range(NULL, 0, nplans - 1);
                }
 
@@ -179,7 +174,10 @@ ExecInitAppend(Append *node, EState *estate, int eflags)
                 * immediately, preventing later calls to ExecFindMatchingSubPlans.
                 */
                if (!prunestate->do_exec_prune)
+               {
+                       Assert(nplans > 0);
                        appendstate->as_valid_subplans = bms_add_range(NULL, 0, nplans - 1);
+               }
        }
        else
        {
@@ -189,6 +187,7 @@ ExecInitAppend(Append *node, EState *estate, int eflags)
                 * When run-time partition pruning is not enabled we can just mark all
                 * subplans as valid; they must also all be initialized.
                 */
+               Assert(nplans > 0);
                appendstate->as_valid_subplans = validsubplans =
                        bms_add_range(NULL, 0, nplans - 1);
                appendstate->as_prune_state = NULL;
@@ -197,7 +196,11 @@ ExecInitAppend(Append *node, EState *estate, int eflags)
        /*
         * Initialize result tuple type and slot.
         */
-       ExecInitResultTupleSlotTL(estate, &appendstate->ps);
+       ExecInitResultTupleSlotTL(&appendstate->ps, &TTSOpsVirtual);
+
+       /* node returns slots from each of its subnodes, therefore not fixed */
+       appendstate->ps.resultopsset = true;
+       appendstate->ps.resultopsfixed = false;
 
        appendplanstates = (PlanState **) palloc(nplans *
                                                                                         sizeof(PlanState *));
@@ -330,12 +333,6 @@ ExecEndAppend(AppendState *node)
         */
        for (i = 0; i < nplans; i++)
                ExecEndNode(appendplans[i]);
-
-       /*
-        * release any resources associated with run-time pruning
-        */
-       if (node->as_prune_state)
-               ExecDestroyPartitionPruneState(node->as_prune_state);
 }
 
 void