aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/executor')
-rw-r--r--src/backend/executor/execGrouping.c49
-rw-r--r--src/backend/executor/nodeAgg.c19
-rw-r--r--src/backend/executor/nodeGroup.c7
-rw-r--r--src/backend/executor/nodeMergejoin.c40
-rw-r--r--src/backend/executor/nodeSetOp.c7
-rw-r--r--src/backend/executor/nodeUnique.c7
6 files changed, 60 insertions, 69 deletions
diff --git a/src/backend/executor/execGrouping.c b/src/backend/executor/execGrouping.c
index eed92f6533f..f84c1120db2 100644
--- a/src/backend/executor/execGrouping.c
+++ b/src/backend/executor/execGrouping.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/executor/execGrouping.c,v 1.22 2007/01/05 22:19:27 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/executor/execGrouping.c,v 1.23 2007/01/10 18:06:02 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -183,24 +183,22 @@ execTuplesUnequal(TupleTableSlot *slot1,
* The result is a palloc'd array.
*/
FmgrInfo *
-execTuplesMatchPrepare(TupleDesc tupdesc,
- int numCols,
- AttrNumber *matchColIdx)
+execTuplesMatchPrepare(int numCols,
+ Oid *eqOperators)
{
- FmgrInfo *eqfunctions = (FmgrInfo *) palloc(numCols * sizeof(FmgrInfo));
+ FmgrInfo *eqFunctions = (FmgrInfo *) palloc(numCols * sizeof(FmgrInfo));
int i;
for (i = 0; i < numCols; i++)
{
- AttrNumber att = matchColIdx[i];
- Oid typid = tupdesc->attrs[att - 1]->atttypid;
+ Oid eq_opr = eqOperators[i];
Oid eq_function;
- eq_function = equality_oper_funcid(typid);
- fmgr_info(eq_function, &eqfunctions[i]);
+ eq_function = get_opcode(eq_opr);
+ fmgr_info(eq_function, &eqFunctions[i]);
}
- return eqfunctions;
+ return eqFunctions;
}
/*
@@ -208,40 +206,33 @@ execTuplesMatchPrepare(TupleDesc tupdesc,
* Look up the equality and hashing functions needed for a TupleHashTable.
*
* This is similar to execTuplesMatchPrepare, but we also need to find the
- * hash functions associated with the equality operators. *eqfunctions and
- * *hashfunctions receive the palloc'd result arrays.
+ * hash functions associated with the equality operators. *eqFunctions and
+ * *hashFunctions receive the palloc'd result arrays.
*/
void
-execTuplesHashPrepare(TupleDesc tupdesc,
- int numCols,
- AttrNumber *matchColIdx,
- FmgrInfo **eqfunctions,
- FmgrInfo **hashfunctions)
+execTuplesHashPrepare(int numCols,
+ Oid *eqOperators,
+ FmgrInfo **eqFunctions,
+ FmgrInfo **hashFunctions)
{
int i;
- *eqfunctions = (FmgrInfo *) palloc(numCols * sizeof(FmgrInfo));
- *hashfunctions = (FmgrInfo *) palloc(numCols * sizeof(FmgrInfo));
+ *eqFunctions = (FmgrInfo *) palloc(numCols * sizeof(FmgrInfo));
+ *hashFunctions = (FmgrInfo *) palloc(numCols * sizeof(FmgrInfo));
for (i = 0; i < numCols; i++)
{
- AttrNumber att = matchColIdx[i];
- Oid typid = tupdesc->attrs[att - 1]->atttypid;
- Operator optup;
- Oid eq_opr;
+ Oid eq_opr = eqOperators[i];
Oid eq_function;
Oid hash_function;
- optup = equality_oper(typid, false);
- eq_opr = oprid(optup);
- eq_function = oprfuncid(optup);
- ReleaseSysCache(optup);
+ eq_function = get_opcode(eq_opr);
hash_function = get_op_hash_function(eq_opr);
if (!OidIsValid(hash_function)) /* should not happen */
elog(ERROR, "could not find hash function for hash operator %u",
eq_opr);
- fmgr_info(eq_function, &(*eqfunctions)[i]);
- fmgr_info(hash_function, &(*hashfunctions)[i]);
+ fmgr_info(eq_function, &(*eqFunctions)[i]);
+ fmgr_info(hash_function, &(*hashFunctions)[i]);
}
}
diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c
index 74a00ac8920..00fb3b86e71 100644
--- a/src/backend/executor/nodeAgg.c
+++ b/src/backend/executor/nodeAgg.c
@@ -61,7 +61,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/executor/nodeAgg.c,v 1.148 2007/01/09 02:14:11 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/executor/nodeAgg.c,v 1.149 2007/01/10 18:06:02 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1270,16 +1270,14 @@ ExecInitAgg(Agg *node, EState *estate, int eflags)
if (node->numCols > 0)
{
if (node->aggstrategy == AGG_HASHED)
- execTuplesHashPrepare(ExecGetScanType(&aggstate->ss),
- node->numCols,
- node->grpColIdx,
+ execTuplesHashPrepare(node->numCols,
+ node->grpOperators,
&aggstate->eqfunctions,
&aggstate->hashfunctions);
else
aggstate->eqfunctions =
- execTuplesMatchPrepare(ExecGetScanType(&aggstate->ss),
- node->numCols,
- node->grpColIdx);
+ execTuplesMatchPrepare(node->numCols,
+ node->grpOperators);
}
/*
@@ -1519,6 +1517,13 @@ ExecInitAgg(Agg *node, EState *estate, int eflags)
&peraggstate->inputtypeLen,
&peraggstate->inputtypeByVal);
+ /*
+ * Look up the sorting and comparison operators to use. XXX it's
+ * pretty bletcherous to be making this sort of semantic decision
+ * in the executor. Probably the parser should decide this and
+ * record it in the Aggref node ... or at latest, do it in the
+ * planner.
+ */
eq_function = equality_oper_funcid(inputTypes[0]);
fmgr_info(eq_function, &(peraggstate->equalfn));
peraggstate->sortOperator = ordering_oper_opid(inputTypes[0]);
diff --git a/src/backend/executor/nodeGroup.c b/src/backend/executor/nodeGroup.c
index 417adeda253..da4b2bcdb49 100644
--- a/src/backend/executor/nodeGroup.c
+++ b/src/backend/executor/nodeGroup.c
@@ -15,7 +15,7 @@
* locate group boundaries.
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/executor/nodeGroup.c,v 1.66 2007/01/05 22:19:28 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/executor/nodeGroup.c,v 1.67 2007/01/10 18:06:02 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -211,9 +211,8 @@ ExecInitGroup(Group *node, EState *estate, int eflags)
* Precompute fmgr lookup data for inner loop
*/
grpstate->eqfunctions =
- execTuplesMatchPrepare(ExecGetScanType(&grpstate->ss),
- node->numCols,
- node->grpColIdx);
+ execTuplesMatchPrepare(node->numCols,
+ node->grpOperators);
return grpstate;
}
diff --git a/src/backend/executor/nodeMergejoin.c b/src/backend/executor/nodeMergejoin.c
index 63e9035f546..a5f08c28ef3 100644
--- a/src/backend/executor/nodeMergejoin.c
+++ b/src/backend/executor/nodeMergejoin.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/executor/nodeMergejoin.c,v 1.84 2007/01/05 22:19:28 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/executor/nodeMergejoin.c,v 1.85 2007/01/10 18:06:02 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -156,35 +156,36 @@ typedef struct MergeJoinClauseData
* the two expressions from the original clause.
*
* In addition to the expressions themselves, the planner passes the btree
- * opfamily OID and btree strategy number (BTLessStrategyNumber or
- * BTGreaterStrategyNumber) that identify the intended merge semantics for
- * each merge key. The mergejoinable operator is an equality operator in
- * this opfamily, and the two inputs are guaranteed to be ordered in either
- * increasing or decreasing (respectively) order according to this opfamily.
- * This allows us to obtain the needed comparison functions from the opfamily.
+ * opfamily OID, btree strategy number (BTLessStrategyNumber or
+ * BTGreaterStrategyNumber), and nulls-first flag that identify the intended
+ * merge semantics for each merge key. The mergejoinable operator is an
+ * equality operator in this opfamily, and the two inputs are guaranteed to be
+ * ordered in either increasing or decreasing (respectively) order according
+ * to this opfamily. This allows us to obtain the needed comparison functions
+ * from the opfamily.
*/
static MergeJoinClause
-MJExamineQuals(List *mergeclauses, List *mergefamilies, List *mergestrategies,
+MJExamineQuals(List *mergeclauses,
+ Oid *mergefamilies,
+ int *mergestrategies,
+ bool *mergenullsfirst,
PlanState *parent)
{
MergeJoinClause clauses;
int nClauses = list_length(mergeclauses);
int iClause;
ListCell *cl;
- ListCell *cf;
- ListCell *cs;
clauses = (MergeJoinClause) palloc0(nClauses * sizeof(MergeJoinClauseData));
iClause = 0;
- cf = list_head(mergefamilies);
- cs = list_head(mergestrategies);
foreach(cl, mergeclauses)
{
OpExpr *qual = (OpExpr *) lfirst(cl);
MergeJoinClause clause = &clauses[iClause];
- Oid opfamily;
- StrategyNumber opstrategy;
+ Oid opfamily = mergefamilies[iClause];
+ StrategyNumber opstrategy = mergestrategies[iClause];
+ bool nulls_first = mergenullsfirst[iClause];
int op_strategy;
Oid op_lefttype;
Oid op_righttype;
@@ -192,14 +193,10 @@ MJExamineQuals(List *mergeclauses, List *mergefamilies, List *mergestrategies,
RegProcedure cmpproc;
AclResult aclresult;
- opfamily = lfirst_oid(cf);
- cf = lnext(cf);
- opstrategy = lfirst_int(cs);
- cs = lnext(cs);
-
/* Later we'll support both ascending and descending sort... */
Assert(opstrategy == BTLessStrategyNumber);
clause->cmpstrategy = MERGEFUNC_CMP;
+ Assert(!nulls_first);
if (!IsA(qual, OpExpr))
elog(ERROR, "mergejoin clause is not an OpExpr");
@@ -1525,8 +1522,9 @@ ExecInitMergeJoin(MergeJoin *node, EState *estate, int eflags)
*/
mergestate->mj_NumClauses = list_length(node->mergeclauses);
mergestate->mj_Clauses = MJExamineQuals(node->mergeclauses,
- node->mergefamilies,
- node->mergestrategies,
+ node->mergeFamilies,
+ node->mergeStrategies,
+ node->mergeNullsFirst,
(PlanState *) mergestate);
/*
diff --git a/src/backend/executor/nodeSetOp.c b/src/backend/executor/nodeSetOp.c
index 6d7c9e3b8b5..761f7fc5947 100644
--- a/src/backend/executor/nodeSetOp.c
+++ b/src/backend/executor/nodeSetOp.c
@@ -21,7 +21,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/executor/nodeSetOp.c,v 1.23 2007/01/05 22:19:28 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/executor/nodeSetOp.c,v 1.24 2007/01/10 18:06:02 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -267,9 +267,8 @@ ExecInitSetOp(SetOp *node, EState *estate, int eflags)
* Precompute fmgr lookup data for inner loop
*/
setopstate->eqfunctions =
- execTuplesMatchPrepare(ExecGetResultType(&setopstate->ps),
- node->numCols,
- node->dupColIdx);
+ execTuplesMatchPrepare(node->numCols,
+ node->dupOperators);
return setopstate;
}
diff --git a/src/backend/executor/nodeUnique.c b/src/backend/executor/nodeUnique.c
index 5e0edfb57ba..6d64c3e334b 100644
--- a/src/backend/executor/nodeUnique.c
+++ b/src/backend/executor/nodeUnique.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/executor/nodeUnique.c,v 1.54 2007/01/05 22:19:28 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/executor/nodeUnique.c,v 1.55 2007/01/10 18:06:02 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -159,9 +159,8 @@ ExecInitUnique(Unique *node, EState *estate, int eflags)
* Precompute fmgr lookup data for inner loop
*/
uniquestate->eqfunctions =
- execTuplesMatchPrepare(ExecGetResultType(&uniquestate->ps),
- node->numCols,
- node->uniqColIdx);
+ execTuplesMatchPrepare(node->numCols,
+ node->uniqOperators);
return uniquestate;
}