8
8
*
9
9
*
10
10
* 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 $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
@@ -467,8 +467,8 @@ transformRangeSubselect(ParseState *pstate, RangeSubselect *r)
467
467
*
468
468
* Aside from the primary return value (the transformed joinlist item)
469
469
* 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.
472
472
*/
473
473
static Node *
474
474
transformFromClauseItem (ParseState * pstate ,Node * n ,List * * containedRels )
@@ -495,7 +495,8 @@ transformFromClauseItem(ParseState *pstate, Node *n, List **containedRels)
495
495
{
496
496
/* A newfangled join expression */
497
497
JoinExpr * j = (JoinExpr * )n ;
498
- List * l_containedRels ,
498
+ List * my_containedRels ,
499
+ * l_containedRels ,
499
500
* r_containedRels ,
500
501
* l_colnames ,
501
502
* r_colnames ,
@@ -517,9 +518,10 @@ transformFromClauseItem(ParseState *pstate, Node *n, List **containedRels)
517
518
j -> rarg = transformFromClauseItem (pstate ,j -> rarg ,& r_containedRels );
518
519
519
520
/*
520
- * Generate combined list of relation indexes
521
+ * Generate combined list of relation indexes for possible use
522
+ * by transformJoinOnClause below.
521
523
*/
522
- * containedRels = nconc (l_containedRels ,r_containedRels );
524
+ my_containedRels = nconc (l_containedRels ,r_containedRels );
523
525
524
526
/*
525
527
* Check for conflicting refnames in left and right subtrees. Must
@@ -705,7 +707,7 @@ transformFromClauseItem(ParseState *pstate, Node *n, List **containedRels)
705
707
else if (j -> quals )
706
708
{
707
709
/* User-written ON-condition; transform it */
708
- j -> quals = transformJoinOnClause (pstate ,j ,* containedRels );
710
+ j -> quals = transformJoinOnClause (pstate ,j ,my_containedRels );
709
711
}
710
712
else
711
713
{
@@ -768,6 +770,11 @@ transformFromClauseItem(ParseState *pstate, Node *n, List **containedRels)
768
770
j -> rtindex = length (pstate -> p_rtable );
769
771
Assert (rte == rt_fetch (j -> rtindex ,pstate -> p_rtable ));
770
772
773
+ /*
774
+ * Include join RTE in returned containedRels list
775
+ */
776
+ * containedRels = lconsi (j -> rtindex ,my_containedRels );
777
+
771
778
return (Node * )j ;
772
779
}
773
780
else