aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeSubplan.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/executor/nodeSubplan.c')
-rw-r--r--src/backend/executor/nodeSubplan.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/backend/executor/nodeSubplan.c b/src/backend/executor/nodeSubplan.c
index f444faf55cc..6b6f4c3f55d 100644
--- a/src/backend/executor/nodeSubplan.c
+++ b/src/backend/executor/nodeSubplan.c
@@ -472,7 +472,7 @@ buildSubPlanHash(SubPlanState *node, ExprContext *econtext)
{
SubPlan *subplan = node->subplan;
PlanState *planstate = node->planstate;
- int ncols = list_length(subplan->paramIds);
+ int ncols = node->numCols;
ExprContext *innerecontext = node->innerecontext;
MemoryContext oldcontext;
long nbuckets;
@@ -874,11 +874,6 @@ ExecInitSubPlan(SubPlan *subplan, PlanState *parent)
ALLOCSET_SMALL_SIZES);
/* and a short-lived exprcontext for function evaluation */
sstate->innerecontext = CreateExprContext(estate);
- /* Silly little array of column numbers 1..n */
- ncols = list_length(subplan->paramIds);
- sstate->keyColIdx = (AttrNumber *) palloc(ncols * sizeof(AttrNumber));
- for (i = 0; i < ncols; i++)
- sstate->keyColIdx[i] = i + 1;
/*
* We use ExecProject to evaluate the lefthand and righthand
@@ -910,9 +905,11 @@ ExecInitSubPlan(SubPlan *subplan, PlanState *parent)
(int) nodeTag(subplan->testexpr));
oplist = NIL; /* keep compiler quiet */
}
- Assert(list_length(oplist) == ncols);
+ ncols = list_length(oplist);
lefttlist = righttlist = NIL;
+ sstate->numCols = ncols;
+ sstate->keyColIdx = (AttrNumber *) palloc(ncols * sizeof(AttrNumber));
sstate->tab_eq_funcoids = (Oid *) palloc(ncols * sizeof(Oid));
sstate->tab_hash_funcs = (FmgrInfo *) palloc(ncols * sizeof(FmgrInfo));
sstate->tab_eq_funcs = (FmgrInfo *) palloc(ncols * sizeof(FmgrInfo));
@@ -971,6 +968,9 @@ ExecInitSubPlan(SubPlan *subplan, PlanState *parent)
fmgr_info(left_hashfn, &sstate->lhs_hash_funcs[i - 1]);
fmgr_info(right_hashfn, &sstate->tab_hash_funcs[i - 1]);
+ /* keyColIdx is just column numbers 1..n */
+ sstate->keyColIdx[i - 1] = i;
+
i++;
}