diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-09-01 20:42:46 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-09-01 20:42:46 +0000 |
commit | b153c0920960a6059b67969469166fb29c0105d7 (patch) | |
tree | 4e7100ecdca88746c369ae2a6a43468925f3194d /src/backend/parser/parse_agg.c | |
parent | 9ac4299163247645c6e391f5f65735c6cb78ccb9 (diff) | |
download | postgresql-b153c0920960a6059b67969469166fb29c0105d7.tar.gz postgresql-b153c0920960a6059b67969469166fb29c0105d7.zip |
Add a bunch of new error location reports to parse-analysis error messages.
There are still some weak spots around JOIN USING and relation alias lists,
but most errors reported within backend/parser/ now have locations.
Diffstat (limited to 'src/backend/parser/parse_agg.c')
-rw-r--r-- | src/backend/parser/parse_agg.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/backend/parser/parse_agg.c b/src/backend/parser/parse_agg.c index 215557396f9..d85f64c7abc 100644 --- a/src/backend/parser/parse_agg.c +++ b/src/backend/parser/parse_agg.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_agg.c,v 1.82 2008/08/28 23:09:47 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_agg.c,v 1.83 2008/09/01 20:42:44 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -70,7 +70,9 @@ transformAggregateCall(ParseState *pstate, Aggref *agg) if (checkExprHasAggs((Node *) agg->args)) ereport(ERROR, (errcode(ERRCODE_GROUPING_ERROR), - errmsg("aggregate function calls cannot be nested"))); + errmsg("aggregate function calls cannot be nested"), + parser_errposition(pstate, + locate_agg_of_level((Node *) agg->args, 0)))); } if (min_varlevel < 0) @@ -117,11 +119,15 @@ parseCheckAggregates(ParseState *pstate, Query *qry) if (checkExprHasAggs(qry->jointree->quals)) ereport(ERROR, (errcode(ERRCODE_GROUPING_ERROR), - errmsg("aggregates not allowed in WHERE clause"))); + errmsg("aggregates not allowed in WHERE clause"), + parser_errposition(pstate, + locate_agg_of_level(qry->jointree->quals, 0)))); if (checkExprHasAggs((Node *) qry->jointree->fromlist)) ereport(ERROR, (errcode(ERRCODE_GROUPING_ERROR), - errmsg("aggregates not allowed in JOIN conditions"))); + errmsg("aggregates not allowed in JOIN conditions"), + parser_errposition(pstate, + locate_agg_of_level((Node *) qry->jointree->fromlist, 0)))); /* * No aggregates allowed in GROUP BY clauses, either. @@ -140,7 +146,9 @@ parseCheckAggregates(ParseState *pstate, Query *qry) if (checkExprHasAggs(expr)) ereport(ERROR, (errcode(ERRCODE_GROUPING_ERROR), - errmsg("aggregates not allowed in GROUP BY clause"))); + errmsg("aggregates not allowed in GROUP BY clause"), + parser_errposition(pstate, + locate_agg_of_level(expr, 0)))); groupClauses = lcons(expr, groupClauses); } @@ -327,13 +335,14 @@ check_ungrouped_columns_walker(Node *node, ereport(ERROR, (errcode(ERRCODE_GROUPING_ERROR), errmsg("column \"%s.%s\" must appear in the GROUP BY clause or be used in an aggregate function", - rte->eref->aliasname, attname))); + rte->eref->aliasname, attname), + parser_errposition(context->pstate, var->location))); else ereport(ERROR, (errcode(ERRCODE_GROUPING_ERROR), errmsg("subquery uses ungrouped column \"%s.%s\" from outer query", - rte->eref->aliasname, attname))); - + rte->eref->aliasname, attname), + parser_errposition(context->pstate, var->location))); } if (IsA(node, Query)) |