* ExecReScan * Reset a plan node so that its output can be re-scanned. * * Note that if the plan node has parameters that have changed value, * the output might be different from last time. */
| 92 | * the output might be different from last time. |
| 93 | */ |
| 94 | void |
| 95 | ExecReScan(PlanState *node) |
| 96 | { |
| 97 | /* If collecting timing stats, update them */ |
| 98 | if (node->instrument) |
| 99 | InstrEndLoop(node->instrument); |
| 100 | |
| 101 | /* no longer squelched */ |
| 102 | node->squelched = false; |
| 103 | |
| 104 | /* |
| 105 | * If we have changed parameters, propagate that info. |
| 106 | * |
| 107 | * Note: ExecReScanSetParamPlan() can add bits to node->chgParam, |
| 108 | * corresponding to the output param(s) that the InitPlan will update. |
| 109 | * Since we make only one pass over the list, that means that an InitPlan |
| 110 | * can depend on the output param(s) of a sibling InitPlan only if that |
| 111 | * sibling appears earlier in the list. This is workable for now given |
| 112 | * the limited ways in which one InitPlan could depend on another, but |
| 113 | * eventually we might need to work harder (or else make the planner |
| 114 | * enlarge the extParam/allParam sets to include the params of depended-on |
| 115 | * InitPlans). |
| 116 | */ |
| 117 | if (node->chgParam != NULL) |
| 118 | { |
| 119 | ListCell *l; |
| 120 | |
| 121 | foreach(l, node->initPlan) |
| 122 | { |
| 123 | SubPlanState *sstate = (SubPlanState *) lfirst(l); |
| 124 | PlanState *splan = sstate->planstate; |
| 125 | |
| 126 | /* |
| 127 | * If 'splan' is NULL, then InitPlan() thought it was "alien". We |
| 128 | * should not get here then, but let's sanity check. |
| 129 | */ |
| 130 | if (splan == NULL) |
| 131 | elog(ERROR, "subplan not initialized in this slice"); |
| 132 | |
| 133 | if (splan->plan->extParam != NULL) /* don't care about child |
| 134 | * local Params */ |
| 135 | UpdateChangedParamSet(splan, node->chgParam); |
| 136 | if (splan->chgParam != NULL) |
| 137 | ExecReScanSetParamPlan(sstate, node); |
| 138 | } |
| 139 | foreach(l, node->subPlan) |
| 140 | { |
| 141 | SubPlanState *sstate = (SubPlanState *) lfirst(l); |
| 142 | PlanState *splan = sstate->planstate; |
| 143 | |
| 144 | /* |
| 145 | * If 'splan' is NULL, then InitPlan() thought it was "alien". We |
| 146 | * should not get here then, but let's sanity check. |
| 147 | */ |
| 148 | if (splan == NULL) |
| 149 | elog(ERROR, "subplan not initialized in this slice"); |
| 150 | |
| 151 | if (splan->plan->extParam != NULL) |
no test coverage detected