diff options
author | Andres Freund <andres@anarazel.de> | 2018-02-15 22:39:18 -0800 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2018-02-15 22:39:18 -0800 |
commit | 2a41507dab0f293ff241fe8ae326065998668af8 (patch) | |
tree | 30fe1118750ea9c2805bd38a7485390f4d381715 /src/backend/executor/nodeSetOp.c | |
parent | 773aec7aa98abd38d6d9435913bb8e14e392c274 (diff) | |
download | postgresql-2a41507dab0f293ff241fe8ae326065998668af8.tar.gz postgresql-2a41507dab0f293ff241fe8ae326065998668af8.zip |
Revert "Do execGrouping.c via expression eval machinery."
This reverts commit 773aec7aa98abd38d6d9435913bb8e14e392c274.
There's an unresolved issue in the reverted commit: It only creates
one comparator function, but in for the nodeSubplan.c case we need
more (c.f. FindTupleHashEntry vs LookupTupleHashEntry calls in
nodeSubplan.c).
This isn't too difficult to fix, but it's not entirely trivial
either. The fact that the issue only causes breakage on 32bit systems
shows that the current test coverage isn't that great. To avoid
turning half the buildfarm red till those two issues are addressed,
revert.
Diffstat (limited to 'src/backend/executor/nodeSetOp.c')
-rw-r--r-- | src/backend/executor/nodeSetOp.c | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/src/backend/executor/nodeSetOp.c b/src/backend/executor/nodeSetOp.c index ba2d3159c0c..c91c3402d25 100644 --- a/src/backend/executor/nodeSetOp.c +++ b/src/backend/executor/nodeSetOp.c @@ -120,22 +120,18 @@ static void build_hash_table(SetOpState *setopstate) { SetOp *node = (SetOp *) setopstate->ps.plan; - ExprContext *econtext = setopstate->ps.ps_ExprContext; - TupleDesc desc = ExecGetResultType(outerPlanState(setopstate)); Assert(node->strategy == SETOP_HASHED); Assert(node->numGroups > 0); - setopstate->hashtable = BuildTupleHashTable(&setopstate->ps, - desc, - node->numCols, + setopstate->hashtable = BuildTupleHashTable(node->numCols, node->dupColIdx, setopstate->eqfunctions, setopstate->hashfunctions, node->numGroups, 0, setopstate->tableContext, - econtext->ecxt_per_tuple_memory, + setopstate->tempContext, false); } @@ -224,11 +220,11 @@ ExecSetOp(PlanState *pstate) static TupleTableSlot * setop_retrieve_direct(SetOpState *setopstate) { + SetOp *node = (SetOp *) setopstate->ps.plan; PlanState *outerPlan; SetOpStatePerGroup pergroup; TupleTableSlot *outerslot; TupleTableSlot *resultTupleSlot; - ExprContext *econtext = setopstate->ps.ps_ExprContext; /* * get state info from node @@ -296,10 +292,11 @@ setop_retrieve_direct(SetOpState *setopstate) /* * Check whether we've crossed a group boundary. */ - econtext->ecxt_outertuple = resultTupleSlot; - econtext->ecxt_innertuple = outerslot; - - if (!ExecQualAndReset(setopstate->eqfunction, econtext)) + if (!execTuplesMatch(resultTupleSlot, + outerslot, + node->numCols, node->dupColIdx, + setopstate->eqfunctions, + setopstate->tempContext)) { /* * Save the first input tuple of the next group. @@ -341,7 +338,6 @@ setop_fill_hash_table(SetOpState *setopstate) PlanState *outerPlan; int firstFlag; bool in_first_rel PG_USED_FOR_ASSERTS_ONLY; - ExprContext *econtext = setopstate->ps.ps_ExprContext; /* * get state info from node @@ -408,8 +404,8 @@ setop_fill_hash_table(SetOpState *setopstate) advance_counts((SetOpStatePerGroup) entry->additional, flag); } - /* Must reset expression context after each hashtable lookup */ - ResetExprContext(econtext); + /* Must reset temp context after each hashtable lookup */ + MemoryContextReset(setopstate->tempContext); } setopstate->table_filled = true; @@ -480,7 +476,6 @@ SetOpState * ExecInitSetOp(SetOp *node, EState *estate, int eflags) { SetOpState *setopstate; - TupleDesc outerDesc; /* check for unsupported flags */ Assert(!(eflags & (EXEC_FLAG_BACKWARD | EXEC_FLAG_MARK))); @@ -503,9 +498,16 @@ ExecInitSetOp(SetOp *node, EState *estate, int eflags) setopstate->tableContext = NULL; /* - * create expression context + * Miscellaneous initialization + * + * SetOp nodes have no ExprContext initialization because they never call + * ExecQual or ExecProject. But they do need a per-tuple memory context + * anyway for calling execTuplesMatch. */ - ExecAssignExprContext(estate, &setopstate->ps); + setopstate->tempContext = + AllocSetContextCreate(CurrentMemoryContext, + "SetOp", + ALLOCSET_DEFAULT_SIZES); /* * If hashing, we also need a longer-lived context to store the hash @@ -532,7 +534,6 @@ ExecInitSetOp(SetOp *node, EState *estate, int eflags) if (node->strategy == SETOP_HASHED) eflags &= ~EXEC_FLAG_REWIND; outerPlanState(setopstate) = ExecInitNode(outerPlan(node), estate, eflags); - outerDesc = ExecGetResultType(outerPlanState(setopstate)); /* * setop nodes do no projections, so initialize projection info for this @@ -552,12 +553,9 @@ ExecInitSetOp(SetOp *node, EState *estate, int eflags) &setopstate->eqfunctions, &setopstate->hashfunctions); else - setopstate->eqfunction = - execTuplesMatchPrepare(outerDesc, - node->numCols, - node->dupColIdx, - node->dupOperators, - &setopstate->ps); + setopstate->eqfunctions = + execTuplesMatchPrepare(node->numCols, + node->dupOperators); if (node->strategy == SETOP_HASHED) { @@ -587,9 +585,9 @@ ExecEndSetOp(SetOpState *node) ExecClearTuple(node->ps.ps_ResultTupleSlot); /* free subsidiary stuff including hashtable */ + MemoryContextDelete(node->tempContext); if (node->tableContext) MemoryContextDelete(node->tableContext); - ExecFreeExprContext(&node->ps); ExecEndNode(outerPlanState(node)); } |