From 18c30002863a1a4d2c2f0da6d245f106586bc686 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 10 Dec 1999 07:37:35 +0000 Subject: Teach grammar and parser about aggregate(DISTINCT ...). No implementation yet, but at least we can give a better error message: regression=> select count(distinct f1) from int4_tbl; ERROR: aggregate(DISTINCT ...) is not implemented yet instead of 'parser: parse error at or near distinct'. --- src/include/nodes/parsenodes.h | 15 +++++++++++++-- src/include/parser/parse_agg.h | 5 +++-- src/include/parser/parse_func.h | 8 +++++--- 3 files changed, 21 insertions(+), 7 deletions(-) (limited to 'src/include') diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index bcff7aa300..df0cb5c4e5 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: parsenodes.h,v 1.89 1999/12/10 03:56:09 momjian Exp $ + * $Id: parsenodes.h,v 1.90 1999/12/10 07:37:32 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -758,6 +758,10 @@ typedef struct SelectStmt /**************************************************************************** * Supporting data structures for Parse Trees + * + * Most of these node types appear in raw parsetrees output by the grammar, + * and get transformed to something else by the analyzer. A few of them + * are used as-is in transformed querytrees. ****************************************************************************/ /* @@ -889,13 +893,20 @@ typedef struct Ident } Ident; /* - * FuncCall - a function/aggregate invocation + * FuncCall - a function or aggregate invocation + * + * agg_star indicates we saw a 'foo(*)' construct, while agg_distinct + * indicates we saw 'foo(DISTINCT ...)'. In either case, the construct + * *must* be an aggregate call. Otherwise, it might be either an + * aggregate or some other kind of function. */ typedef struct FuncCall { NodeTag type; char *funcname; /* name of function */ List *args; /* the arguments (list of exprs) */ + bool agg_star; /* argument was really '*' */ + bool agg_distinct; /* arguments were labeled DISTINCT */ } FuncCall; /* diff --git a/src/include/parser/parse_agg.h b/src/include/parser/parse_agg.h index f1b400e9c9..cd149e1517 100644 --- a/src/include/parser/parse_agg.h +++ b/src/include/parser/parse_agg.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: parse_agg.h,v 1.12 1999/07/15 23:04:01 momjian Exp $ + * $Id: parse_agg.h,v 1.13 1999/12/10 07:37:33 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -18,7 +18,8 @@ extern void AddAggToParseState(ParseState *pstate, Aggref *aggref); extern void parseCheckAggregates(ParseState *pstate, Query *qry); extern Aggref *ParseAgg(ParseState *pstate, char *aggname, Oid basetype, - List *target, int precedence); + List *args, bool agg_star, bool agg_distinct, + int precedence); extern void agg_error(char *caller, char *aggname, Oid basetypeID); #endif /* PARSE_AGG_H */ diff --git a/src/include/parser/parse_func.h b/src/include/parser/parse_func.h index 1fdb8f9890..04b9c44ec0 100644 --- a/src/include/parser/parse_func.h +++ b/src/include/parser/parse_func.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: parse_func.h,v 1.19 1999/08/21 03:49:17 tgl Exp $ + * $Id: parse_func.h,v 1.20 1999/12/10 07:37:33 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -42,8 +42,10 @@ typedef struct _CandidateList extern Node *ParseNestedFuncOrColumn(ParseState *pstate, Attr *attr, int *curr_resno, int precedence); -extern Node *ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs, - int *curr_resno, int precedence); +extern Node *ParseFuncOrColumn(ParseState *pstate, + char *funcname, List *fargs, + bool agg_star, bool agg_distinct, + int *curr_resno, int precedence); extern List *setup_base_tlist(Oid typeid); -- cgit v1.2.1