diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2003-06-06 15:04:03 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2003-06-06 15:04:03 +0000 |
| commit | e649796f128bd8702ba5744d36f4e8cb81f0b754 (patch) | |
| tree | 050eda51ad8f0298731316ccf61db2c01a2863a3 /src/include | |
| parent | 2c93861f7cef99b4613abd37ed7e4c15a95754b4 (diff) | |
| download | postgresql-e649796f128bd8702ba5744d36f4e8cb81f0b754.tar.gz | |
Implement outer-level aggregates to conform to the SQL spec, with
extensions to support our historical behavior. An aggregate belongs
to the closest query level of any of the variables in its argument,
or the current query level if there are no variables (e.g., COUNT(*)).
The implementation involves adding an agglevelsup field to Aggref,
and treating outer aggregates like outer variables at planning time.
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/catalog/catversion.h | 4 | ||||
| -rw-r--r-- | src/include/nodes/primnodes.h | 3 | ||||
| -rw-r--r-- | src/include/optimizer/subselect.h | 5 | ||||
| -rw-r--r-- | src/include/optimizer/var.h | 3 | ||||
| -rw-r--r-- | src/include/parser/parse_agg.h | 4 |
5 files changed, 12 insertions, 7 deletions
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index 443af8e8d6..209bd5ff24 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -37,7 +37,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: catversion.h,v 1.197 2003/05/28 16:03:59 tgl Exp $ + * $Id: catversion.h,v 1.198 2003/06/06 15:04:02 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 200305271 +#define CATALOG_VERSION_NO 200306051 #endif diff --git a/src/include/nodes/primnodes.h b/src/include/nodes/primnodes.h index 558621c900..12af0fd092 100644 --- a/src/include/nodes/primnodes.h +++ b/src/include/nodes/primnodes.h @@ -10,7 +10,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: primnodes.h,v 1.82 2003/05/06 00:20:33 tgl Exp $ + * $Id: primnodes.h,v 1.83 2003/06/06 15:04:03 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -223,6 +223,7 @@ typedef struct Aggref Oid aggfnoid; /* pg_proc Oid of the aggregate */ Oid aggtype; /* type Oid of result of the aggregate */ Expr *target; /* expression we are aggregating on */ + Index agglevelsup; /* > 0 if agg belongs to outer query */ bool aggstar; /* TRUE if argument was really '*' */ bool aggdistinct; /* TRUE if it's agg(DISTINCT ...) */ } Aggref; diff --git a/src/include/optimizer/subselect.h b/src/include/optimizer/subselect.h index 9dce88e0a8..c3c7462d04 100644 --- a/src/include/optimizer/subselect.h +++ b/src/include/optimizer/subselect.h @@ -5,18 +5,19 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: subselect.h,v 1.18 2003/02/09 00:30:41 tgl Exp $ + * $Id: subselect.h,v 1.19 2003/06/06 15:04:03 tgl Exp $ * *------------------------------------------------------------------------- */ #ifndef SUBSELECT_H #define SUBSELECT_H +#include "nodes/parsenodes.h" #include "nodes/plannodes.h" extern Index PlannerQueryLevel; /* level of current query */ extern List *PlannerInitPlan; /* init subplans for current query */ -extern List *PlannerParamVar; /* to get Var from Param->paramid */ +extern List *PlannerParamList; /* to keep track of cross-level Params */ extern int PlannerPlanId; /* to assign unique ID to subquery plans */ extern Node *convert_IN_to_join(Query *parse, SubLink *sublink); diff --git a/src/include/optimizer/var.h b/src/include/optimizer/var.h index 3c84020ef9..82124627f7 100644 --- a/src/include/optimizer/var.h +++ b/src/include/optimizer/var.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: var.h,v 1.26 2003/02/08 20:20:55 tgl Exp $ + * $Id: var.h,v 1.27 2003/06/06 15:04:03 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -24,6 +24,7 @@ extern bool contain_whole_tuple_var(Node *node, int varno, int levelsup); extern bool contain_var_clause(Node *node); extern bool contain_vars_of_level(Node *node, int levelsup); extern bool contain_vars_above_level(Node *node, int levelsup); +extern int find_minimum_var_level(Node *node); extern List *pull_var_clause(Node *node, bool includeUpperVars); extern Node *flatten_join_alias_vars(Query *root, Node *node); diff --git a/src/include/parser/parse_agg.h b/src/include/parser/parse_agg.h index 111d726bc9..bc1e601cc2 100644 --- a/src/include/parser/parse_agg.h +++ b/src/include/parser/parse_agg.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: parse_agg.h,v 1.25 2003/01/17 03:25:04 tgl Exp $ + * $Id: parse_agg.h,v 1.26 2003/06/06 15:04:03 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -15,6 +15,8 @@ #include "parser/parse_node.h" +extern void transformAggregateCall(ParseState *pstate, Aggref *agg); + extern void parseCheckAggregates(ParseState *pstate, Query *qry); #endif /* PARSE_AGG_H */ |
