diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/catalog/catversion.h | 4 | ||||
-rw-r--r-- | src/include/executor/nodeGroup.h | 12 | ||||
-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 | ||||
-rw-r--r-- | src/include/optimizer/planmain.h | 4 | ||||
-rw-r--r-- | src/include/optimizer/tlist.h | 5 | ||||
-rw-r--r-- | src/include/parser/parse_clause.h | 6 |
8 files changed, 53 insertions, 24 deletions
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index e8e2f971b01..d6d8ff6ffba 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -37,7 +37,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: catversion.h,v 1.12 2000/01/26 05:57:56 momjian Exp $ + * $Id: catversion.h,v 1.13 2000/01/27 18:11:40 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 200001241 +#define CATALOG_VERSION_NO 200001271 #endif diff --git a/src/include/executor/nodeGroup.h b/src/include/executor/nodeGroup.h index afe510d5eaf..dd104b0af94 100644 --- a/src/include/executor/nodeGroup.h +++ b/src/include/executor/nodeGroup.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: nodeGroup.h,v 1.14 2000/01/26 23:48:05 tgl Exp $ + * $Id: nodeGroup.h,v 1.15 2000/01/27 18:11:41 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -22,4 +22,14 @@ extern int ExecCountSlotsGroup(Group *node); extern void ExecEndGroup(Group *node); extern void ExecReScanGroup(Group *node, ExprContext *exprCtxt, Plan *parent); +extern bool execTuplesMatch(HeapTuple tuple1, + HeapTuple tuple2, + TupleDesc tupdesc, + int numCols, + AttrNumber *matchColIdx, + FmgrInfo *eqfunctions); +extern FmgrInfo *execTuplesMatchPrepare(TupleDesc tupdesc, + int numCols, + AttrNumber *matchColIdx); + #endif /* NODEGROUP_H */ diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index a6a337087ae..827bb75a9c8 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 1346ac8a04e..288e7f96b8d 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 19216d36381..ff83431e580 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; diff --git a/src/include/optimizer/planmain.h b/src/include/optimizer/planmain.h index 826c5dbe3ce..340f54485cb 100644 --- a/src/include/optimizer/planmain.h +++ b/src/include/optimizer/planmain.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: planmain.h,v 1.36 2000/01/26 05:58:20 momjian Exp $ + * $Id: planmain.h,v 1.37 2000/01/27 18:11:45 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -33,7 +33,7 @@ extern Agg *make_agg(List *tlist, Plan *lefttree); extern Group *make_group(List *tlist, bool tuplePerGroup, int ngrp, AttrNumber *grpColIdx, Plan *lefttree); extern Noname *make_noname(List *tlist, List *pathkeys, Plan *subplan); -extern Unique *make_unique(List *tlist, Plan *lefttree, char *uniqueAttr); +extern Unique *make_unique(List *tlist, Plan *lefttree, List *distinctList); extern Result *make_result(List *tlist, Node *resconstantqual, Plan *subplan); /* diff --git a/src/include/optimizer/tlist.h b/src/include/optimizer/tlist.h index 986c47ee796..dba93c0d173 100644 --- a/src/include/optimizer/tlist.h +++ b/src/include/optimizer/tlist.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: tlist.h,v 1.23 2000/01/26 05:58:21 momjian Exp $ + * $Id: tlist.h,v 1.24 2000/01/27 18:11:45 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -28,6 +28,9 @@ extern List *flatten_tlist(List *tlist); extern List *add_to_flat_tlist(List *tlist, List *vars); extern Var *get_expr(TargetEntry *tle); + +extern TargetEntry *get_sortgroupclause_tle(SortClause *sortClause, + List *targetList); extern Node *get_sortgroupclause_expr(SortClause *sortClause, List *targetList); diff --git a/src/include/parser/parse_clause.h b/src/include/parser/parse_clause.h index 5d0b2badf16..235a02bc4c2 100644 --- a/src/include/parser/parse_clause.h +++ b/src/include/parser/parse_clause.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: parse_clause.h,v 1.14 2000/01/26 05:58:26 momjian Exp $ + * $Id: parse_clause.h,v 1.15 2000/01/27 18:11:47 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -23,7 +23,9 @@ extern Node *transformWhereClause(ParseState *pstate, Node *where, extern List *transformGroupClause(ParseState *pstate, List *grouplist, List *targetlist); extern List *transformSortClause(ParseState *pstate, List *orderlist, - List *targetlist, char *uniqueFlag); + List *targetlist); +extern List *transformDistinctClause(ParseState *pstate, List *distinctlist, + List *targetlist, List **sortClause); extern List *addAllTargetsToSortList(List *sortlist, List *targetlist); extern Index assignSortGroupRef(TargetEntry *tle, List *tlist); |