diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2004-04-18 18:13:31 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2004-04-18 18:13:31 +0000 |
commit | 9086c46f224b184496a15d94f9242b60fceb4afb (patch) | |
tree | d55a7860f89a5f0305036c23f4f48873abffa325 /src/backend/parser/parse_clause.c | |
parent | 2510c867d6c7f5db1dc721542d8f7ebe9e110d9a (diff) | |
download | postgresql-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_clause.c')
-rw-r--r-- | src/backend/parser/parse_clause.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c index 20937ad2b69..7bf9490ed59 100644 --- a/src/backend/parser/parse_clause.c +++ b/src/backend/parser/parse_clause.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.124 2003/09/26 15:27:35 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.124.2.1 2004/04/18 18:13:31 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1112,10 +1112,18 @@ findTargetlistEntry(ParseState *pstate, Node *node, List *tlist, int clause) * is a matching column. If so, fall through to let * transformExpr() do the rest. NOTE: if name could refer * ambiguously to more than one column name exposed by FROM, - * colnameToVar will ereport(ERROR). That's just what we want + * colNameToVar will ereport(ERROR). That's just what we want * here. + * + * Small tweak for 7.4.3: ignore matches in upper query levels. + * This effectively changes the search order for bare names to + * (1) local FROM variables, (2) local targetlist aliases, + * (3) outer FROM variables, whereas before it was (1) (3) (2). + * SQL92 and SQL99 do not allow GROUPing BY an outer reference, + * so this breaks no cases that are legal per spec, and it + * seems a more self-consistent behavior. */ - if (colnameToVar(pstate, name) != NULL) + if (colNameToVar(pstate, name, true) != NULL) name = NULL; } |