From 505b5185fc37a53fbdcd27e26f163fb0c532d136 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 23 May 1999 21:41:14 +0000 Subject: Detect case of invalid use of GROUP BY when there are no aggregate functions, as in select a, b from foo group by a; The ungrouped reference to b is not kosher, but formerly we neglected to check this unless there was an aggregate function somewhere in the query. --- src/backend/parser/analyze.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/backend/parser/analyze.c') diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c index 23158f3751..14c8150ff0 100644 --- a/src/backend/parser/analyze.c +++ b/src/backend/parser/analyze.c @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: analyze.c,v 1.106 1999/05/17 17:03:27 momjian Exp $ + * $Id: analyze.c,v 1.107 1999/05/23 21:41:14 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -373,7 +373,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt) qry->uniqueFlag); qry->hasAggs = pstate->p_hasAggs; - if (pstate->p_hasAggs) + if (pstate->p_hasAggs || qry->groupClause) parseCheckAggregates(pstate, qry); /* @@ -997,7 +997,7 @@ transformSelectStmt(ParseState *pstate, SelectStmt *stmt) qry->rtable = pstate->p_rtable; qry->hasAggs = pstate->p_hasAggs; - if (pstate->p_hasAggs) + if (pstate->p_hasAggs || qry->groupClause) parseCheckAggregates(pstate, qry); /* -- cgit v1.2.1