mirror of
https://github.com/postgres/postgres.git
synced 2025-06-14 18:42:34 +03:00
Fix oversight in recent change of representation for JOIN alias
variables: JOIN/ON should allow references to contained JOINs. Per bug report from Barry Lind.
This commit is contained in:
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.87 2002/03/26 19:15:57 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.88 2002/04/15 06:05:49 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -467,8 +467,8 @@ transformRangeSubselect(ParseState *pstate, RangeSubselect *r)
|
|||||||
*
|
*
|
||||||
* Aside from the primary return value (the transformed joinlist item)
|
* Aside from the primary return value (the transformed joinlist item)
|
||||||
* this routine also returns an integer list of the rangetable indexes
|
* this routine also returns an integer list of the rangetable indexes
|
||||||
* of all the base relations represented in the joinlist item. This
|
* of all the base and join relations represented in the joinlist item.
|
||||||
* list is needed for checking JOIN/ON conditions in higher levels.
|
* This list is needed for checking JOIN/ON conditions in higher levels.
|
||||||
*/
|
*/
|
||||||
static Node *
|
static Node *
|
||||||
transformFromClauseItem(ParseState *pstate, Node *n, List **containedRels)
|
transformFromClauseItem(ParseState *pstate, Node *n, List **containedRels)
|
||||||
@ -495,7 +495,8 @@ transformFromClauseItem(ParseState *pstate, Node *n, List **containedRels)
|
|||||||
{
|
{
|
||||||
/* A newfangled join expression */
|
/* A newfangled join expression */
|
||||||
JoinExpr *j = (JoinExpr *) n;
|
JoinExpr *j = (JoinExpr *) n;
|
||||||
List *l_containedRels,
|
List *my_containedRels,
|
||||||
|
*l_containedRels,
|
||||||
*r_containedRels,
|
*r_containedRels,
|
||||||
*l_colnames,
|
*l_colnames,
|
||||||
*r_colnames,
|
*r_colnames,
|
||||||
@ -517,9 +518,10 @@ transformFromClauseItem(ParseState *pstate, Node *n, List **containedRels)
|
|||||||
j->rarg = transformFromClauseItem(pstate, j->rarg, &r_containedRels);
|
j->rarg = transformFromClauseItem(pstate, j->rarg, &r_containedRels);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generate combined list of relation indexes
|
* Generate combined list of relation indexes for possible use
|
||||||
|
* by transformJoinOnClause below.
|
||||||
*/
|
*/
|
||||||
*containedRels = nconc(l_containedRels, r_containedRels);
|
my_containedRels = nconc(l_containedRels, r_containedRels);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check for conflicting refnames in left and right subtrees. Must
|
* Check for conflicting refnames in left and right subtrees. Must
|
||||||
@ -705,7 +707,7 @@ transformFromClauseItem(ParseState *pstate, Node *n, List **containedRels)
|
|||||||
else if (j->quals)
|
else if (j->quals)
|
||||||
{
|
{
|
||||||
/* User-written ON-condition; transform it */
|
/* User-written ON-condition; transform it */
|
||||||
j->quals = transformJoinOnClause(pstate, j, *containedRels);
|
j->quals = transformJoinOnClause(pstate, j, my_containedRels);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -768,6 +770,11 @@ transformFromClauseItem(ParseState *pstate, Node *n, List **containedRels)
|
|||||||
j->rtindex = length(pstate->p_rtable);
|
j->rtindex = length(pstate->p_rtable);
|
||||||
Assert(rte == rt_fetch(j->rtindex, pstate->p_rtable));
|
Assert(rte == rt_fetch(j->rtindex, pstate->p_rtable));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Include join RTE in returned containedRels list
|
||||||
|
*/
|
||||||
|
*containedRels = lconsi(j->rtindex, my_containedRels);
|
||||||
|
|
||||||
return (Node *) j;
|
return (Node *) j;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user