aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_relation.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-04-18 18:13:31 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-04-18 18:13:31 +0000
commit9086c46f224b184496a15d94f9242b60fceb4afb (patch)
treed55a7860f89a5f0305036c23f4f48873abffa325 /src/backend/parser/parse_relation.c
parent2510c867d6c7f5db1dc721542d8f7ebe9e110d9a (diff)
downloadpostgresql-9086c46f224b184496a15d94f9242b60fceb4afb.tar.gz
postgresql-9086c46f224b184496a15d94f9242b60fceb4afb.zip
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.
Diffstat (limited to 'src/backend/parser/parse_relation.c')
-rw-r--r--src/backend/parser/parse_relation.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c
index 7f8bda311c0..e12367641d5 100644
--- a/src/backend/parser/parse_relation.c
+++ b/src/backend/parser/parse_relation.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.90 2003/09/25 06:58:01 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.90.2.1 2004/04/18 18:13:31 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -513,13 +513,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;
@@ -576,8 +577,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++;