88 *
99 *
1010 * IDENTIFICATION
11- * $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.87 2002/03/26 19:15:57 tgl Exp $
11+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.88 2002/04/15 06:05:49 tgl Exp $
1212 *
1313 *-------------------------------------------------------------------------
1414 */
@@ -467,8 +467,8 @@ transformRangeSubselect(ParseState *pstate, RangeSubselect *r)
467467 *
468468 * Aside from the primary return value (the transformed joinlist item)
469469 * this routine also returns an integer list of the rangetable indexes
470- * of all the base relations represented in the joinlist item. This
471- * list is needed for checking JOIN/ON conditions in higher levels.
470+ * of all the baseand join relations represented in the joinlist item.
471+ *This list is needed for checking JOIN/ON conditions in higher levels.
472472 */
473473static Node *
474474transformFromClauseItem (ParseState * pstate ,Node * n ,List * * containedRels )
@@ -495,7 +495,8 @@ transformFromClauseItem(ParseState *pstate, Node *n, List **containedRels)
495495{
496496/* A newfangled join expression */
497497JoinExpr * j = (JoinExpr * )n ;
498- List * l_containedRels ,
498+ List * my_containedRels ,
499+ * l_containedRels ,
499500* r_containedRels ,
500501* l_colnames ,
501502* r_colnames ,
@@ -517,9 +518,10 @@ transformFromClauseItem(ParseState *pstate, Node *n, List **containedRels)
517518j -> rarg = transformFromClauseItem (pstate ,j -> rarg ,& r_containedRels );
518519
519520/*
520- * Generate combined list of relation indexes
521+ * Generate combined list of relation indexes for possible use
522+ * by transformJoinOnClause below.
521523 */
522- * containedRels = nconc (l_containedRels ,r_containedRels );
524+ my_containedRels = nconc (l_containedRels ,r_containedRels );
523525
524526/*
525527 * Check for conflicting refnames in left and right subtrees. Must
@@ -705,7 +707,7 @@ transformFromClauseItem(ParseState *pstate, Node *n, List **containedRels)
705707else if (j -> quals )
706708{
707709/* User-written ON-condition; transform it */
708- j -> quals = transformJoinOnClause (pstate ,j ,* containedRels );
710+ j -> quals = transformJoinOnClause (pstate ,j ,my_containedRels );
709711}
710712else
711713{
@@ -768,6 +770,11 @@ transformFromClauseItem(ParseState *pstate, Node *n, List **containedRels)
768770j -> rtindex = length (pstate -> p_rtable );
769771Assert (rte == rt_fetch (j -> rtindex ,pstate -> p_rtable ));
770772
773+ /*
774+ * Include join RTE in returned containedRels list
775+ */
776+ * containedRels = lconsi (j -> rtindex ,my_containedRels );
777+
771778return (Node * )j ;
772779}
773780else