mirror of
https://github.com/postgres/postgres.git
synced 2025-06-16 06:01:02 +03:00
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.
This commit is contained in:
@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user