aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeUnique.c
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2018-02-15 21:55:31 -0800
committerAndres Freund <andres@anarazel.de>2018-02-16 14:38:13 -0800
commitbf6c614a2f2c58312b3be34a47e7fb7362e07bcb (patch)
treebbc91aed13afc3ef3b71bada700322197fe40b69 /src/backend/executor/nodeUnique.c
parentad9a274778d2d88c46b90309212b92ee7fdf9afe (diff)
downloadpostgresql-bf6c614a2f2c58312b3be34a47e7fb7362e07bcb.tar.gz
postgresql-bf6c614a2f2c58312b3be34a47e7fb7362e07bcb.zip
Do execGrouping.c via expression eval machinery, take two.
This has a performance benefit on own, although not hugely so. The primary benefit is that it will allow for to JIT tuple deforming and comparator invocations. Large parts of this were previously committed (773aec7aa), but the commit contained an omission around cross-type comparisons and was thus reverted. Author: Andres Freund Discussion: https://postgr.es/m/20171129080934.amqqkke2zjtekd4t@alap3.anarazel.de
Diffstat (limited to 'src/backend/executor/nodeUnique.c')
-rw-r--r--src/backend/executor/nodeUnique.c31
1 files changed, 13 insertions, 18 deletions
diff --git a/src/backend/executor/nodeUnique.c b/src/backend/executor/nodeUnique.c
index e330650593a..9f823c58e1a 100644
--- a/src/backend/executor/nodeUnique.c
+++ b/src/backend/executor/nodeUnique.c
@@ -47,7 +47,7 @@ static TupleTableSlot * /* return: a tuple or NULL */
ExecUnique(PlanState *pstate)
{
UniqueState *node = castNode(UniqueState, pstate);
- Unique *plannode = (Unique *) node->ps.plan;
+ ExprContext *econtext = node->ps.ps_ExprContext;
TupleTableSlot *resultTupleSlot;
TupleTableSlot *slot;
PlanState *outerPlan;
@@ -89,10 +89,9 @@ ExecUnique(PlanState *pstate)
* If so then we loop back and fetch another new tuple from the
* subplan.
*/
- if (!execTuplesMatch(slot, resultTupleSlot,
- plannode->numCols, plannode->uniqColIdx,
- node->eqfunctions,
- node->tempContext))
+ econtext->ecxt_innertuple = slot;
+ econtext->ecxt_outertuple = resultTupleSlot;
+ if (!ExecQualAndReset(node->eqfunction, econtext))
break;
}
@@ -129,16 +128,9 @@ ExecInitUnique(Unique *node, EState *estate, int eflags)
uniquestate->ps.ExecProcNode = ExecUnique;
/*
- * Miscellaneous initialization
- *
- * Unique 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.
+ * create expression context
*/
- uniquestate->tempContext =
- AllocSetContextCreate(CurrentMemoryContext,
- "Unique",
- ALLOCSET_DEFAULT_SIZES);
+ ExecAssignExprContext(estate, &uniquestate->ps);
/*
* Tuple table initialization
@@ -160,9 +152,12 @@ ExecInitUnique(Unique *node, EState *estate, int eflags)
/*
* Precompute fmgr lookup data for inner loop
*/
- uniquestate->eqfunctions =
- execTuplesMatchPrepare(node->numCols,
- node->uniqOperators);
+ uniquestate->eqfunction =
+ execTuplesMatchPrepare(ExecGetResultType(outerPlanState(uniquestate)),
+ node->numCols,
+ node->uniqColIdx,
+ node->uniqOperators,
+ &uniquestate->ps);
return uniquestate;
}
@@ -180,7 +175,7 @@ ExecEndUnique(UniqueState *node)
/* clean up tuple table */
ExecClearTuple(node->ps.ps_ResultTupleSlot);
- MemoryContextDelete(node->tempContext);
+ ExecFreeExprContext(&node->ps);
ExecEndNode(outerPlanState(node));
}