MCPcopy Create free account
hub / github.com/apache/cloudberry / ExecInitSubPlan

Function ExecInitSubPlan

src/backend/executor/nodeSubplan.c:807–1064  ·  view source on GitHub ↗

---------------------------------------------------------------- * 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

Source from the content-addressed store, hash-verified

805 * ----------------------------------------------------------------
806 */
807SubPlanState *
808ExecInitSubPlan(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

Callers 2

ExecInitNodeFunction · 0.85
ExecInitExprRecFunction · 0.85

Calls 15

list_nthFunction · 0.85
bms_is_memberFunction · 0.85
ExecInitExprFunction · 0.85
ExecInitExprListFunction · 0.85
CreateExprContextFunction · 0.85
is_andclauseFunction · 0.85
list_lengthFunction · 0.85
makeTargetEntryFunction · 0.85
lappendFunction · 0.85
fmgr_infoFunction · 0.85
get_opcodeFunction · 0.85

Tested by

no test coverage detected