]> granicus.if.org Git - postgresql/blobdiff - src/backend/executor/nodeAppend.c
Make some small planner API cleanups.
[postgresql] / src / backend / executor / nodeAppend.c
index 6dd53e90ba8ec53c9251d8dc3e175ec41f1c593d..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,15 +123,17 @@ 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;
 
                /* We may need an expression context to evaluate partition exprs */
                ExecAssignExprContext(estate, &appendstate->ps);
 
-               prunestate = ExecSetupPartitionPruneState(&appendstate->ps,
-                                                                                                 node->part_prune_infos);
+               /* Create the working data structure for pruning. */
+               prunestate = ExecCreatePartitionPruneState(&appendstate->ps,
+                                                                                                  node->part_prune_info);
+               appendstate->as_prune_state = prunestate;
 
                /* Perform an initial partition prune, if required. */
                if (prunestate->do_initial_prune)
@@ -169,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);
                }
 
@@ -177,9 +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);
-
-               appendstate->as_prune_state = prunestate;
+               }
        }
        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 *));