diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2001-02-14 21:35:07 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2001-02-14 21:35:07 +0000 |
commit | 4a66f9dd54694eb4d7ecce2c7e0f0c50dfde88cd (patch) | |
tree | 8810441569d5cf2e29f2a5c2b67ceb91d74deb2d /src/backend/parser/parse_func.c | |
parent | d42d31e78e2f9db73edb0b0ed35cafb1c409bdbf (diff) | |
download | postgresql-4a66f9dd54694eb4d7ecce2c7e0f0c50dfde88cd.tar.gz postgresql-4a66f9dd54694eb4d7ecce2c7e0f0c50dfde88cd.zip |
Change scoping of table and join refnames to conform to SQL92: a JOIN
clause with an alias is a <subquery> and therefore hides table references
appearing within it, according to the spec. This is the same as the
preliminary patch I posted to pgsql-patches yesterday, plus some really
grotty code in ruleutils.c to reverse-list a query tree with the correct
alias name depending on context. I'd rather not have done that, but unless
we want to force another initdb for 7.1, there's no other way for now.
Diffstat (limited to 'src/backend/parser/parse_func.c')
-rw-r--r-- | src/backend/parser/parse_func.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c index cb4914849b4..e0d2b515526 100644 --- a/src/backend/parser/parse_func.c +++ b/src/backend/parser/parse_func.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.98 2001/01/24 19:43:02 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.99 2001/02/14 21:35:04 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -427,6 +427,7 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs, { RangeTblEntry *rte; int vnum; + Node *rteorjoin; int sublevels_up; /* @@ -434,9 +435,29 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs, */ refname = ((Ident *) arg)->name; - rte = refnameRangeTableEntry(pstate, refname); - if (rte == NULL) + rteorjoin = refnameRangeOrJoinEntry(pstate, refname, + &sublevels_up); + + if (rteorjoin == NULL) + { rte = addImplicitRTE(pstate, refname); + } + else if (IsA(rteorjoin, RangeTblEntry)) + { + rte = (RangeTblEntry *) rteorjoin; + } + else if (IsA(rteorjoin, JoinExpr)) + { + elog(ERROR, + "function applied to tuple is not supported for joins"); + rte = NULL; /* keep compiler quiet */ + } + else + { + elog(ERROR, "ParseFuncOrColumn: unexpected node type %d", + nodeTag(rteorjoin)); + rte = NULL; /* keep compiler quiet */ + } vnum = RTERangeTablePosn(pstate, rte, &sublevels_up); |