diff options
Diffstat (limited to 'src/backend/parser/parse_agg.c')
-rw-r--r-- | src/backend/parser/parse_agg.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/backend/parser/parse_agg.c b/src/backend/parser/parse_agg.c index 380d9d35605..5854f81005d 100644 --- a/src/backend/parser/parse_agg.c +++ b/src/backend/parser/parse_agg.c @@ -181,6 +181,16 @@ transformAggregateCall(ParseState *pstate, Aggref *agg, while (min_varlevel-- > 0) pstate = pstate->parentParseState; pstate->p_hasAggs = true; + + /* + * Complain if we are inside a LATERAL subquery of the aggregation query. + * We must be in its FROM clause, so the aggregate is misplaced. + */ + if (pstate->p_lateral_active) + ereport(ERROR, + (errcode(ERRCODE_GROUPING_ERROR), + errmsg("aggregates not allowed in FROM clause"), + parser_errposition(pstate, agg->location))); } /* |