diff options
Diffstat (limited to 'src/include/nodes')
| -rw-r--r-- | src/include/nodes/execnodes.h | 16 | ||||
| -rw-r--r-- | src/include/nodes/parsenodes.h | 20 | ||||
| -rw-r--r-- | src/include/nodes/plannodes.h | 10 |
3 files changed, 30 insertions, 16 deletions
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index a6a337087a..827bb75a9c 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: execnodes.h,v 1.39 2000/01/26 05:58:15 momjian Exp $ + * $Id: execnodes.h,v 1.40 2000/01/27 18:11:44 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -621,6 +621,7 @@ typedef struct AggState 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; @@ -663,9 +664,9 @@ typedef struct SortState * Unique nodes are used "on top of" sort nodes to discard * duplicate tuples returned from the sort phase. Basically * all it does is compare the current tuple from the subplan - * with the previously fetched tuple stored in OuterTuple and - * if the two are identical, then we just fetch another tuple - * from the sort and try again. + * with the previously fetched tuple stored in priorTuple. + * If the two are identical in all interesting fields, then + * we just fetch another tuple from the sort and try again. * * CommonState information * @@ -677,7 +678,12 @@ typedef struct SortState * ScanAttributes attribute numbers of interest in this tuple * ---------------- */ -typedef CommonState UniqueState; +typedef struct UniqueState +{ + CommonState cstate; /* its first field is NodeTag */ + FmgrInfo *eqfunctions; /* per-field lookup data for equality fns */ + HeapTuple priorTuple; /* most recently returned tuple, or NULL */ +} UniqueState; /* ---------------- diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index 1346ac8a04..288e7f96b8 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: parsenodes.h,v 1.96 2000/01/26 05:58:16 momjian Exp $ + * $Id: parsenodes.h,v 1.97 2000/01/27 18:11:44 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -54,7 +54,8 @@ typedef struct Query Node *qual; /* qualifications applied to tuples */ List *rowMark; /* list of RowMark entries */ - char *uniqueFlag; /* NULL, '*', or Unique attribute name */ + List *distinctClause; /* a list of SortClause's */ + List *sortClause; /* a list of SortClause's */ List *groupClause; /* a list of GroupClause's */ @@ -733,7 +734,8 @@ typedef struct InsertStmt { NodeTag type; char *relname; /* relation to insert into */ - char *unique; /* NULL, '*', or unique attribute name */ + List *distinctClause; /* NULL, list of DISTINCT ON exprs, or + * lcons(NIL,NIL) for all (SELECT DISTINCT) */ List *cols; /* names of the columns */ List *targetList; /* the target list (of ResTarget) */ List *fromClause; /* the from clause */ @@ -777,7 +779,8 @@ typedef struct UpdateStmt typedef struct SelectStmt { NodeTag type; - char *unique; /* NULL, '*', or unique attribute name */ + List *distinctClause; /* NULL, list of DISTINCT ON exprs, or + * lcons(NIL,NIL) for all (SELECT DISTINCT) */ char *into; /* name of table (for select into table) */ List *targetList; /* the target list (of ResTarget) */ List *fromClause; /* the from clause */ @@ -1135,6 +1138,13 @@ typedef struct RangeTblEntry * tleSortGroupRef must match ressortgroupref of exactly one Resdom of the * associated targetlist; that is the expression to be sorted (or grouped) by. * sortop is the OID of the ordering operator. + * + * SortClauses are also used to identify Resdoms that we will do a "Unique" + * filter step on (for SELECT DISTINCT and SELECT DISTINCT ON). The + * distinctClause list is simply a copy of the relevant members of the + * sortClause list. Note that distinctClause can be a subset of sortClause, + * but cannot have members not present in sortClause; and the members that + * do appear must be in the same order as in sortClause. */ typedef struct SortClause { @@ -1148,7 +1158,7 @@ typedef struct SortClause * representation of GROUP BY clauses * * GroupClause is exactly like SortClause except for the nodetag value - * (and it's probably not even really necessary to have two different + * (it's probably not even really necessary to have two different * nodetags...). We have routines that operate interchangeably on both. */ typedef SortClause GroupClause; diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h index 19216d3638..ff83431e58 100644 --- a/src/include/nodes/plannodes.h +++ b/src/include/nodes/plannodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: plannodes.h,v 1.36 2000/01/26 05:58:16 momjian Exp $ + * $Id: plannodes.h,v 1.37 2000/01/27 18:11:44 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -265,7 +265,7 @@ typedef struct Group Plan plan; bool tuplePerGroup; /* what tuples to return (see above) */ int numCols; /* number of group columns */ - AttrNumber *grpColIdx; /* index into the target list */ + AttrNumber *grpColIdx; /* indexes into the target list */ GroupState *grpstate; } Group; @@ -314,10 +314,8 @@ typedef struct Unique Plan plan; /* noname node flattened out */ Oid nonameid; int keycount; - char *uniqueAttr; /* NULL if all attrs, or unique attribute - * name */ - AttrNumber uniqueAttrNum; /* attribute number of attribute to select - * distinct on */ + int numCols; /* number of columns to check for uniqueness */ + AttrNumber *uniqColIdx; /* indexes into the target list */ UniqueState *uniquestate; } Unique; |
