aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeGroup.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/nodeGroup.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/nodeGroup.c')
-rw-r--r--src/backend/executor/nodeGroup.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/backend/executor/nodeGroup.c b/src/backend/executor/nodeGroup.c
index f1cdbaa4e67..8f7bf459efe 100644
--- a/src/backend/executor/nodeGroup.c
+++ b/src/backend/executor/nodeGroup.c
@@ -25,6 +25,7 @@
#include "executor/executor.h"
#include "executor/nodeGroup.h"
#include "miscadmin.h"
+#include "utils/memutils.h"
/*
@@ -37,8 +38,6 @@ ExecGroup(PlanState *pstate)
{
GroupState *node = castNode(GroupState, pstate);
ExprContext *econtext;
- int numCols;
- AttrNumber *grpColIdx;
TupleTableSlot *firsttupleslot;
TupleTableSlot *outerslot;
@@ -50,8 +49,6 @@ ExecGroup(PlanState *pstate)
if (node->grp_done)
return NULL;
econtext = node->ss.ps.ps_ExprContext;
- numCols = ((Group *) node->ss.ps.plan)->numCols;
- grpColIdx = ((Group *) node->ss.ps.plan)->grpColIdx;
/*
* The ScanTupleSlot holds the (copied) first tuple of each group.
@@ -59,7 +56,7 @@ ExecGroup(PlanState *pstate)
firsttupleslot = node->ss.ss_ScanTupleSlot;
/*
- * We need not call ResetExprContext here because execTuplesMatch will
+ * We need not call ResetExprContext here because ExecQualAndReset() will
* reset the per-tuple memory context once per input tuple.
*/
@@ -124,10 +121,9 @@ ExecGroup(PlanState *pstate)
* Compare with first tuple and see if this tuple is of the same
* group. If so, ignore it and keep scanning.
*/
- if (!execTuplesMatch(firsttupleslot, outerslot,
- numCols, grpColIdx,
- node->eqfunctions,
- econtext->ecxt_per_tuple_memory))
+ econtext->ecxt_innertuple = firsttupleslot;
+ econtext->ecxt_outertuple = outerslot;
+ if (!ExecQualAndReset(node->eqfunction, econtext))
break;
}
@@ -166,6 +162,7 @@ GroupState *
ExecInitGroup(Group *node, EState *estate, int eflags)
{
GroupState *grpstate;
+ AttrNumber *grpColIdx = grpColIdx = node->grpColIdx;
/* check for unsupported flags */
Assert(!(eflags & (EXEC_FLAG_BACKWARD | EXEC_FLAG_MARK)));
@@ -215,9 +212,12 @@ ExecInitGroup(Group *node, EState *estate, int eflags)
/*
* Precompute fmgr lookup data for inner loop
*/
- grpstate->eqfunctions =
- execTuplesMatchPrepare(node->numCols,
- node->grpOperators);
+ grpstate->eqfunction =
+ execTuplesMatchPrepare(ExecGetResultType(outerPlanState(grpstate)),
+ node->numCols,
+ grpColIdx,
+ node->grpOperators,
+ &grpstate->ss.ps);
return grpstate;
}