---------------------------------------------------------------- * ExecInitAppend * * Begin all of the subscans of the append node. * * (This is potentially wasteful, since the entire result of the * append node may not be scanned, but this way all of the * structures get allocated in the executor's top level memory * block instead of that of the call to ExecAppend.) * -----------
| 107 | * ---------------------------------------------------------------- |
| 108 | */ |
| 109 | AppendState * |
| 110 | ExecInitAppend(Append *node, EState *estate, int eflags) |
| 111 | { |
| 112 | AppendState *appendstate = makeNode(AppendState); |
| 113 | PlanState **appendplanstates; |
| 114 | Bitmapset *validsubplans; |
| 115 | Bitmapset *asyncplans; |
| 116 | int nplans; |
| 117 | int nasyncplans; |
| 118 | int firstvalid; |
| 119 | int i, |
| 120 | j; |
| 121 | |
| 122 | /* check for unsupported flags */ |
| 123 | Assert(!(eflags & EXEC_FLAG_MARK)); |
| 124 | |
| 125 | /* |
| 126 | * create new AppendState for our append node |
| 127 | */ |
| 128 | appendstate->ps.plan = (Plan *) node; |
| 129 | appendstate->ps.state = estate; |
| 130 | appendstate->ps.ExecProcNode = ExecAppend; |
| 131 | |
| 132 | /* Let choose_next_subplan_* function handle setting the first subplan */ |
| 133 | appendstate->as_whichplan = INVALID_SUBPLAN_INDEX; |
| 134 | appendstate->as_syncdone = false; |
| 135 | appendstate->as_begun = false; |
| 136 | |
| 137 | /* If run-time partition pruning is enabled, then set that up now */ |
| 138 | if (node->part_prune_info != NULL) |
| 139 | { |
| 140 | PartitionPruneState *prunestate; |
| 141 | |
| 142 | /* We may need an expression context to evaluate partition exprs */ |
| 143 | ExecAssignExprContext(estate, &appendstate->ps); |
| 144 | |
| 145 | /* Create the working data structure for pruning. */ |
| 146 | prunestate = ExecCreatePartitionPruneState(&appendstate->ps, |
| 147 | node->part_prune_info); |
| 148 | appendstate->as_prune_state = prunestate; |
| 149 | |
| 150 | /* Perform an initial partition prune, if required. */ |
| 151 | if (prunestate->do_initial_prune) |
| 152 | { |
| 153 | /* Determine which subplans survive initial pruning */ |
| 154 | validsubplans = ExecFindInitialMatchingSubPlans(prunestate, |
| 155 | list_length(node->appendplans)); |
| 156 | |
| 157 | nplans = bms_num_members(validsubplans); |
| 158 | } |
| 159 | else |
| 160 | { |
| 161 | /* We'll need to initialize all subplans */ |
| 162 | nplans = list_length(node->appendplans); |
| 163 | Assert(nplans > 0); |
| 164 | validsubplans = bms_add_range(NULL, 0, nplans - 1); |
| 165 | } |
| 166 |
no test coverage detected