diff options
Diffstat (limited to 'src/backend/executor/nodeSubplan.c')
-rw-r--r-- | src/backend/executor/nodeSubplan.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/backend/executor/nodeSubplan.c b/src/backend/executor/nodeSubplan.c index 38c2fc0b50b..9a7962518ee 100644 --- a/src/backend/executor/nodeSubplan.c +++ b/src/backend/executor/nodeSubplan.c @@ -471,7 +471,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; @@ -878,11 +878,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 @@ -914,13 +909,15 @@ 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_collations = (Oid *) palloc(ncols * sizeof(Oid)); sstate->tab_hash_funcs = (FmgrInfo *) palloc(ncols * sizeof(FmgrInfo)); sstate->tab_eq_funcs = (FmgrInfo *) palloc(ncols * sizeof(FmgrInfo)); - sstate->tab_collations = (Oid *) palloc(ncols * sizeof(Oid)); sstate->lhs_hash_funcs = (FmgrInfo *) palloc(ncols * sizeof(FmgrInfo)); sstate->cur_eq_funcs = (FmgrInfo *) palloc(ncols * sizeof(FmgrInfo)); /* we'll need the cross-type equality fns below, but not in sstate */ @@ -979,6 +976,9 @@ ExecInitSubPlan(SubPlan *subplan, PlanState *parent) /* Set collation */ sstate->tab_collations[i - 1] = opexpr->inputcollid; + /* keyColIdx is just column numbers 1..n */ + sstate->keyColIdx[i - 1] = i; + i++; } |