summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/executor/nodeHash.h3
-rw-r--r--src/include/nodes/execnodes.h36
-rw-r--r--src/include/nodes/plannodes.h3
-rw-r--r--src/include/optimizer/clauses.h3
4 files changed, 29 insertions, 16 deletions
diff --git a/src/include/executor/nodeHash.h b/src/include/executor/nodeHash.h
index aed6bb0cf6..8bea51e8af 100644
--- a/src/include/executor/nodeHash.h
+++ b/src/include/executor/nodeHash.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: nodeHash.h,v 1.24 2002/06/20 20:29:49 momjian Exp $
+ * $Id: nodeHash.h,v 1.25 2002/11/06 22:31:24 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -36,5 +36,6 @@ extern void ExecChooseHashTableSize(double ntuples, int tupwidth,
int *virtualbuckets,
int *physicalbuckets,
int *numbatches);
+extern uint32 ComputeHashFunc(Datum key, int typLen, bool byVal);
#endif /* NODEHASH_H */
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 533d296186..f62d1cb815 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: execnodes.h,v 1.76 2002/11/06 00:00:44 tgl Exp $
+ * $Id: execnodes.h,v 1.77 2002/11/06 22:31:24 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -661,12 +661,18 @@ typedef struct MaterialState
*
* csstate.css_ScanTupleSlot refers to output of underlying plan.
*
- * Note: the associated ExprContext contains ecxt_aggvalues and ecxt_aggnulls
- * arrays, which hold the computed agg values for the current input group
- * during evaluation of an Agg node's output tuple(s).
+ * Note: csstate.cstate.cs_ExprContext contains ecxt_aggvalues and
+ * ecxt_aggnulls arrays, which hold the computed agg values for the current
+ * input group during evaluation of an Agg node's output tuple(s). We
+ * create a second ExprContext, tmpcontext, in which to evaluate input
+ * expressions and run the aggregate transition functions.
* -------------------------
*/
-typedef struct AggStatePerAggData *AggStatePerAgg; /* private in nodeAgg.c */
+/* these structs are private in nodeAgg.c: */
+typedef struct AggStatePerAggData *AggStatePerAgg;
+typedef struct AggStatePerGroupData *AggStatePerGroup;
+typedef struct AggHashEntryData *AggHashEntry;
+typedef struct AggHashTableData *AggHashTable;
typedef struct AggState
{
@@ -674,13 +680,18 @@ typedef struct AggState
List *aggs; /* all Aggref nodes in targetlist & quals */
int numaggs; /* length of list (could be zero!) */
FmgrInfo *eqfunctions; /* per-grouping-field equality fns */
- HeapTuple grp_firstTuple; /* copy of first tuple of current group */
- AggStatePerAgg peragg; /* per-Aggref working state */
- MemoryContext tup_cxt; /* context for per-output-tuple
- * expressions */
- MemoryContext agg_cxt[2]; /* pair of expression eval memory contexts */
- int which_cxt; /* 0 or 1, indicates current agg_cxt */
+ AggStatePerAgg peragg; /* per-Aggref information */
+ MemoryContext aggcontext; /* memory context for long-lived data */
+ ExprContext *tmpcontext; /* econtext for input expressions */
bool agg_done; /* indicates completion of Agg scan */
+ /* these fields are used in AGG_PLAIN and AGG_SORTED modes: */
+ AggStatePerGroup pergroup; /* per-Aggref-per-group working state */
+ HeapTuple grp_firstTuple; /* copy of first tuple of current group */
+ /* these fields are used in AGG_HASHED mode: */
+ AggHashTable hashtable; /* hash table with one entry per group */
+ bool table_filled; /* hash table filled yet? */
+ AggHashEntry next_hash_entry; /* next entry in current chain */
+ int next_hash_bucket; /* next chain */
} AggState;
/* ---------------------
@@ -691,9 +702,8 @@ typedef struct GroupState
{
CommonScanState csstate; /* its first field is NodeTag */
FmgrInfo *eqfunctions; /* per-field lookup data for equality fns */
- bool grp_useFirstTuple; /* first tuple not processed yet */
- bool grp_done;
HeapTuple grp_firstTuple; /* copy of first tuple of current group */
+ bool grp_done; /* indicates completion of Group scan */
} GroupState;
/* ----------------
diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h
index 63c8f20d80..0cf9d0bac9 100644
--- a/src/include/nodes/plannodes.h
+++ b/src/include/nodes/plannodes.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: plannodes.h,v 1.59 2002/11/06 00:00:44 tgl Exp $
+ * $Id: plannodes.h,v 1.60 2002/11/06 22:31:24 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -349,6 +349,7 @@ typedef struct Agg
AggStrategy aggstrategy;
int numCols; /* number of grouping columns */
AttrNumber *grpColIdx; /* their indexes in the target list */
+ long numGroups; /* estimated number of groups in input */
AggState *aggstate;
} Agg;
diff --git a/src/include/optimizer/clauses.h b/src/include/optimizer/clauses.h
index 844e7d9490..1cf8fbaf83 100644
--- a/src/include/optimizer/clauses.h
+++ b/src/include/optimizer/clauses.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: clauses.h,v 1.54 2002/09/11 14:48:55 tgl Exp $
+ * $Id: clauses.h,v 1.55 2002/11/06 22:31:24 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -40,6 +40,7 @@ extern Expr *make_ands_explicit(List *andclauses);
extern List *make_ands_implicit(Expr *clause);
extern bool contain_agg_clause(Node *clause);
+extern bool contain_distinct_agg_clause(Node *clause);
extern List *pull_agg_clause(Node *clause);
extern bool expression_returns_set(Node *clause);