* 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
*
*
/* 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
*/
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;
/* 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. */
/*
* 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
+ * an Append 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
{
/* We'll need to initialize all subplans */
nplans = list_length(node->appendplans);
+ Assert(nplans > 0);
validsubplans = bms_add_range(NULL, 0, nplans - 1);
}
* 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
{
* 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;
/*
* 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 *));
*/
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