1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-17 17:02:08 +03:00

Tweak findTargetlistEntry so that bare names occurring in GROUP BY clauses

are sought first as local FROM columns, then as local SELECT-list aliases,
and finally as outer FROM columns; the former behavior made outer FROM
columns take precedence over aliases.  This does not change spec
conformance because SQL99 allows only the first case anyway, and it seems
more useful and self-consistent.  Per gripe from Dennis Bjorklund 2004-04-05.
This commit is contained in:
Tom Lane
2004-04-18 18:12:58 +00:00
parent 3e2aef58a2
commit b5e52b080c
4 changed files with 21 additions and 12 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/parse_relation.c,v 1.93 2004/04/02 19:06:58 tgl Exp $
* $PostgreSQL: pgsql/src/backend/parser/parse_relation.c,v 1.94 2004/04/18 18:12:58 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -531,13 +531,14 @@ scanRTEForColumn(ParseState *pstate, RangeTblEntry *rte, char *colname)
}
/*
* colnameToVar
* colNameToVar
* Search for an unqualified column name.
* If found, return the appropriate Var node (or expression).
* If not found, return NULL. If the name proves ambiguous, raise error.
* If localonly is true, only names in the innermost query are considered.
*/
Node *
colnameToVar(ParseState *pstate, char *colname)
colNameToVar(ParseState *pstate, char *colname, bool localonly)
{
Node *result = NULL;
ParseState *orig_pstate = pstate;
@ -594,8 +595,8 @@ colnameToVar(ParseState *pstate, char *colname)
}
}
if (result != NULL)
break; /* found */
if (result != NULL || localonly)
break; /* found, or don't want to look at parent */
pstate = pstate->parentParseState;
levels_up++;