0002-remove-alternativesubplan-executor-2.patch
text/x-diff
Filename: 0002-remove-alternativesubplan-executor-2.patch
Type: text/x-diff
Part: 1
Patch
Format: unified
Series: patch 0002
| File | + | − |
|---|---|---|
| src/backend/executor/execExpr.c | 0 | 17 |
| src/backend/executor/execExprInterp.c | 0 | 23 |
| src/backend/executor/nodeSubplan.c | 0 | 80 |
| src/backend/jit/llvm/llvmjit_expr.c | 0 | 6 |
| src/backend/jit/llvm/llvmjit_types.c | 0 | 1 |
| src/backend/utils/adt/ruleutils.c | 6 | 1 |
| src/include/executor/execExpr.h | 0 | 10 |
| src/include/executor/nodeSubplan.h | 0 | 4 |
| src/include/nodes/execnodes.h | 0 | 12 |
| src/include/nodes/nodes.h | 0 | 1 |
diff --git a/src/backend/executor/execExpr.c b/src/backend/executor/execExpr.c
index 236413f62a..868f8b0858 100644
--- a/src/backend/executor/execExpr.c
+++ b/src/backend/executor/execExpr.c
@@ -1104,23 +1104,6 @@ ExecInitExprRec(Expr *node, ExprState *state,
break;
}
- case T_AlternativeSubPlan:
- {
- AlternativeSubPlan *asplan = (AlternativeSubPlan *) node;
- AlternativeSubPlanState *asstate;
-
- if (!state->parent)
- elog(ERROR, "AlternativeSubPlan found with no parent plan");
-
- asstate = ExecInitAlternativeSubPlan(asplan, state->parent);
-
- scratch.opcode = EEOP_ALTERNATIVE_SUBPLAN;
- scratch.d.alternative_subplan.asstate = asstate;
-
- ExprEvalPushStep(state, &scratch);
- break;
- }
-
case T_FieldSelect:
{
FieldSelect *fselect = (FieldSelect *) node;
diff --git a/src/backend/executor/execExprInterp.c b/src/backend/executor/execExprInterp.c
index b812bbacee..26c2b49632 100644
--- a/src/backend/executor/execExprInterp.c
+++ b/src/backend/executor/execExprInterp.c
@@ -431,7 +431,6 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
&&CASE_EEOP_GROUPING_FUNC,
&&CASE_EEOP_WINDOW_FUNC,
&&CASE_EEOP_SUBPLAN,
- &&CASE_EEOP_ALTERNATIVE_SUBPLAN,
&&CASE_EEOP_AGG_STRICT_DESERIALIZE,
&&CASE_EEOP_AGG_DESERIALIZE,
&&CASE_EEOP_AGG_STRICT_INPUT_CHECK_ARGS,
@@ -1536,14 +1535,6 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
EEO_NEXT();
}
- EEO_CASE(EEOP_ALTERNATIVE_SUBPLAN)
- {
- /* too complex for an inline implementation */
- ExecEvalAlternativeSubPlan(state, op, econtext);
-
- EEO_NEXT();
- }
-
/* evaluate a strict aggregate deserialization function */
EEO_CASE(EEOP_AGG_STRICT_DESERIALIZE)
{
@@ -3868,20 +3859,6 @@ ExecEvalSubPlan(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
*op->resvalue = ExecSubPlan(sstate, econtext, op->resnull);
}
-/*
- * Hand off evaluation of an alternative subplan to nodeSubplan.c
- */
-void
-ExecEvalAlternativeSubPlan(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
-{
- AlternativeSubPlanState *asstate = op->d.alternative_subplan.asstate;
-
- /* could potentially be nested, so make sure there's enough stack */
- check_stack_depth();
-
- *op->resvalue = ExecAlternativeSubPlan(asstate, econtext, op->resnull);
-}
-
/*
* Evaluate a wholerow Var expression.
*
diff --git a/src/backend/executor/nodeSubplan.c b/src/backend/executor/nodeSubplan.c
index 9a7962518e..9a706df5f0 100644
--- a/src/backend/executor/nodeSubplan.c
+++ b/src/backend/executor/nodeSubplan.c
@@ -1303,83 +1303,3 @@ ExecReScanSetParamPlan(SubPlanState *node, PlanState *parent)
parent->chgParam = bms_add_member(parent->chgParam, paramid);
}
}
-
-
-/*
- * ExecInitAlternativeSubPlan
- *
- * Initialize for execution of one of a set of alternative subplans.
- */
-AlternativeSubPlanState *
-ExecInitAlternativeSubPlan(AlternativeSubPlan *asplan, PlanState *parent)
-{
- AlternativeSubPlanState *asstate = makeNode(AlternativeSubPlanState);
- double num_calls;
- SubPlan *subplan1;
- SubPlan *subplan2;
- Cost cost1;
- Cost cost2;
- ListCell *lc;
-
- asstate->subplan = asplan;
-
- /*
- * Initialize subplans. (Can we get away with only initializing the one
- * we're going to use?)
- */
- foreach(lc, asplan->subplans)
- {
- SubPlan *sp = lfirst_node(SubPlan, lc);
- SubPlanState *sps = ExecInitSubPlan(sp, parent);
-
- asstate->subplans = lappend(asstate->subplans, sps);
- parent->subPlan = lappend(parent->subPlan, sps);
- }
-
- /*
- * Select the one to be used. For this, we need an estimate of the number
- * of executions of the subplan. We use the number of output rows
- * expected from the parent plan node. This is a good estimate if we are
- * in the parent's targetlist, and an underestimate (but probably not by
- * more than a factor of 2) if we are in the qual.
- */
- num_calls = parent->plan->plan_rows;
-
- /*
- * The planner saved enough info so that we don't have to work very hard
- * to estimate the total cost, given the number-of-calls estimate.
- */
- Assert(list_length(asplan->subplans) == 2);
- subplan1 = (SubPlan *) linitial(asplan->subplans);
- subplan2 = (SubPlan *) lsecond(asplan->subplans);
-
- cost1 = subplan1->startup_cost + num_calls * subplan1->per_call_cost;
- cost2 = subplan2->startup_cost + num_calls * subplan2->per_call_cost;
-
- if (cost1 < cost2)
- asstate->active = 0;
- else
- asstate->active = 1;
-
- return asstate;
-}
-
-/*
- * ExecAlternativeSubPlan
- *
- * Execute one of a set of alternative subplans.
- *
- * Note: in future we might consider changing to different subplans on the
- * fly, in case the original rowcount estimate turns out to be way off.
- */
-Datum
-ExecAlternativeSubPlan(AlternativeSubPlanState *node,
- ExprContext *econtext,
- bool *isNull)
-{
- /* Just pass control to the active subplan */
- SubPlanState *activesp = list_nth_node(SubPlanState,
- node->subplans, node->active);
-
- return ExecSubPlan(activesp, econtext, isNull);
-}
diff --git a/src/backend/jit/llvm/llvmjit_expr.c b/src/backend/jit/llvm/llvmjit_expr.c
index cca5c117a0..eb1dea658c 100644
--- a/src/backend/jit/llvm/llvmjit_expr.c
+++ b/src/backend/jit/llvm/llvmjit_expr.c
@@ -1918,12 +1918,6 @@ llvm_compile_expr(ExprState *state)
LLVMBuildBr(b, opblocks[opno + 1]);
break;
- case EEOP_ALTERNATIVE_SUBPLAN:
- build_EvalXFunc(b, mod, "ExecEvalAlternativeSubPlan",
- v_state, op, v_econtext);
- LLVMBuildBr(b, opblocks[opno + 1]);
- break;
-
case EEOP_AGG_STRICT_DESERIALIZE:
case EEOP_AGG_DESERIALIZE:
{
diff --git a/src/backend/jit/llvm/llvmjit_types.c b/src/backend/jit/llvm/llvmjit_types.c
index 0a93d5f665..1ed3cafa2f 100644
--- a/src/backend/jit/llvm/llvmjit_types.c
+++ b/src/backend/jit/llvm/llvmjit_types.c
@@ -102,7 +102,6 @@ void *referenced_functions[] =
ExecAggTransReparent,
ExecEvalAggOrderedTransDatum,
ExecEvalAggOrderedTransTuple,
- ExecEvalAlternativeSubPlan,
ExecEvalArrayCoerce,
ExecEvalArrayExpr,
ExecEvalConstraintCheck,
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 60dd80c23c..0e3084325e 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -8192,7 +8192,12 @@ get_rule_expr(Node *node, deparse_context *context,
AlternativeSubPlan *asplan = (AlternativeSubPlan *) node;
ListCell *lc;
- /* As above, this can only happen during EXPLAIN */
+ /*
+ * This case cannot be reached in normal usage, since no
+ * AlternativeSubPlan can appear either in parsetrees or
+ * finished plan trees. We keep it just in case somebody
+ * wants to use this code to print planner data structures.
+ */
appendStringInfoString(buf, "(alternatives: ");
foreach(lc, asplan->subplans)
{
diff --git a/src/include/executor/execExpr.h b/src/include/executor/execExpr.h
index dbe8649a57..b792de1bc9 100644
--- a/src/include/executor/execExpr.h
+++ b/src/include/executor/execExpr.h
@@ -218,7 +218,6 @@ typedef enum ExprEvalOp
EEOP_GROUPING_FUNC,
EEOP_WINDOW_FUNC,
EEOP_SUBPLAN,
- EEOP_ALTERNATIVE_SUBPLAN,
/* aggregation related nodes */
EEOP_AGG_STRICT_DESERIALIZE,
@@ -589,13 +588,6 @@ typedef struct ExprEvalStep
SubPlanState *sstate;
} subplan;
- /* for EEOP_ALTERNATIVE_SUBPLAN */
- struct
- {
- /* out-of-line state, created by nodeSubplan.c */
- AlternativeSubPlanState *asstate;
- } alternative_subplan;
-
/* for EEOP_AGG_*DESERIALIZE */
struct
{
@@ -734,8 +726,6 @@ extern void ExecEvalXmlExpr(ExprState *state, ExprEvalStep *op);
extern void ExecEvalGroupingFunc(ExprState *state, ExprEvalStep *op);
extern void ExecEvalSubPlan(ExprState *state, ExprEvalStep *op,
ExprContext *econtext);
-extern void ExecEvalAlternativeSubPlan(ExprState *state, ExprEvalStep *op,
- ExprContext *econtext);
extern void ExecEvalWholeRowVar(ExprState *state, ExprEvalStep *op,
ExprContext *econtext);
extern void ExecEvalSysVar(ExprState *state, ExprEvalStep *op,
diff --git a/src/include/executor/nodeSubplan.h b/src/include/executor/nodeSubplan.h
index 83e90b3d07..b629af1f5f 100644
--- a/src/include/executor/nodeSubplan.h
+++ b/src/include/executor/nodeSubplan.h
@@ -18,12 +18,8 @@
extern SubPlanState *ExecInitSubPlan(SubPlan *subplan, PlanState *parent);
-extern AlternativeSubPlanState *ExecInitAlternativeSubPlan(AlternativeSubPlan *asplan, PlanState *parent);
-
extern Datum ExecSubPlan(SubPlanState *node, ExprContext *econtext, bool *isNull);
-extern Datum ExecAlternativeSubPlan(AlternativeSubPlanState *node, ExprContext *econtext, bool *isNull);
-
extern void ExecReScanSetParamPlan(SubPlanState *node, PlanState *parent);
extern void ExecSetParamPlan(SubPlanState *node, ExprContext *econtext);
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 0b42dd6f94..7e02afa6ba 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -880,18 +880,6 @@ typedef struct SubPlanState
ExprState *cur_eq_comp; /* equality comparator for LHS vs. table */
} SubPlanState;
-/* ----------------
- * AlternativeSubPlanState node
- * ----------------
- */
-typedef struct AlternativeSubPlanState
-{
- NodeTag type;
- AlternativeSubPlan *subplan; /* expression plan node */
- List *subplans; /* SubPlanStates of alternative subplans */
- int active; /* list index of the one we're using */
-} AlternativeSubPlanState;
-
/*
* DomainConstraintState - one item to check during CoerceToDomain
*
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h
index 381d84b4e4..7ddd8c011b 100644
--- a/src/include/nodes/nodes.h
+++ b/src/include/nodes/nodes.h
@@ -213,7 +213,6 @@ typedef enum NodeTag
T_WindowFuncExprState,
T_SetExprState,
T_SubPlanState,
- T_AlternativeSubPlanState,
T_DomainConstraintState,
/*