1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-07 00:36:50 +03:00

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.
This commit is contained in:
Tom Lane
1999-05-23 21:41:14 +00:00
parent 57455fc565
commit 505b5185fc
2 changed files with 19 additions and 14 deletions

View File

@ -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);
/*