---------------------------------------------------------------- * ExecInitSubPlan * * Create a SubPlanState for a SubPlan; this is the SubPlan-specific part * of ExecInitExpr(). We split it out so that it can be used for InitPlans * as well as regular SubPlans. Note that we don't link the SubPlan into * the parent's subPlan list, because that shouldn't happen for InitPlans. * Instead, E
| 805 | * ---------------------------------------------------------------- |
| 806 | */ |
| 807 | SubPlanState * |
| 808 | ExecInitSubPlan(SubPlan *subplan, PlanState *parent) |
| 809 | { |
| 810 | SubPlanState *sstate = makeNode(SubPlanState); |
| 811 | EState *estate = parent->state; |
| 812 | |
| 813 | sstate->subplan = subplan; |
| 814 | |
| 815 | /* Link the SubPlanState to already-initialized subplan */ |
| 816 | sstate->planstate = (PlanState *) list_nth(estate->es_subplanstates, |
| 817 | subplan->plan_id - 1); |
| 818 | |
| 819 | /* |
| 820 | * This check can fail if the planner mistakenly puts a parallel-unsafe |
| 821 | * subplan into a parallelized subquery; see ExecSerializePlan. |
| 822 | * |
| 823 | * Initialize only the subplans that are reachable from our local slice. |
| 824 | * If alien elimination is not turned on, then all subplans are considered |
| 825 | * reachable. |
| 826 | */ |
| 827 | if ((!estate->eliminateAliens || |
| 828 | bms_is_member(subplan->plan_id, estate->locallyExecutableSubplans)) && |
| 829 | sstate->planstate == NULL) |
| 830 | elog(ERROR, "subplan \"%s\" was not initialized", |
| 831 | subplan->plan_name); |
| 832 | |
| 833 | /* Link to parent's state, too */ |
| 834 | sstate->parent = parent; |
| 835 | |
| 836 | /* Initialize subexpressions */ |
| 837 | sstate->testexpr = ExecInitExpr((Expr *) subplan->testexpr, parent); |
| 838 | sstate->args = ExecInitExprList(subplan->args, parent); |
| 839 | |
| 840 | /* |
| 841 | * initialize my state |
| 842 | */ |
| 843 | sstate->curTuple = NULL; |
| 844 | sstate->curArray = PointerGetDatum(NULL); |
| 845 | sstate->projLeft = NULL; |
| 846 | sstate->projRight = NULL; |
| 847 | sstate->hashtable = NULL; |
| 848 | sstate->hashnulls = NULL; |
| 849 | sstate->hashtablecxt = NULL; |
| 850 | sstate->hashtempcxt = NULL; |
| 851 | sstate->innerecontext = NULL; |
| 852 | sstate->keyColIdx = NULL; |
| 853 | sstate->tab_eq_funcoids = NULL; |
| 854 | sstate->tab_hash_funcs = NULL; |
| 855 | sstate->tab_eq_funcs = NULL; |
| 856 | sstate->tab_collations = NULL; |
| 857 | sstate->lhs_hash_funcs = NULL; |
| 858 | sstate->cur_eq_funcs = NULL; |
| 859 | sstate->ts_state = NULL; |
| 860 | |
| 861 | /* |
| 862 | * If this is an initplan or MULTIEXPR subplan, it has output parameters |
| 863 | * that the parent plan will use, so mark those parameters as needing |
| 864 | * evaluation. We don't actually run the subplan until we first need one |
no test coverage detected