77 *
88 *
99 * IDENTIFICATION
10- * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/setrefs.c,v 1.54 1999/08/09 00:56:05 tgl Exp $
10+ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/setrefs.c,v 1.55 1999/08/18 04:15:16 tgl Exp $
1111 *
1212 *-------------------------------------------------------------------------
1313 */
@@ -82,10 +82,10 @@ set_tlist_references(Plan *plan)
8282
8383if (IsA_Join (plan ))
8484set_join_tlist_references ((Join * )plan );
85- else if (IsA (plan ,SeqScan )&& plan -> lefttree &&
85+ else if (IsA (plan ,SeqScan )&& plan -> lefttree &&
8686IsA_Noname (plan -> lefttree ))
8787set_nonamescan_tlist_references ((SeqScan * )plan );
88- else if (IsA (plan , Sort ))
88+ else if (IsA_Noname (plan ))
8989set_noname_tlist_references ((Noname * )plan );
9090else if (IsA (plan ,Result ))
9191set_result_tlist_references ((Result * )plan );
@@ -112,12 +112,12 @@ set_tlist_references(Plan *plan)
112112static void
113113set_join_tlist_references (Join * join )
114114{
115- Plan * outer = (( Plan * ) join ) -> lefttree ;
116- Plan * inner = (( Plan * ) join ) -> righttree ;
115+ Plan * outer = join -> lefttree ;
116+ Plan * inner = join -> righttree ;
117117List * outer_tlist = ((outer == NULL ) ?NIL :outer -> targetlist );
118118List * inner_tlist = ((inner == NULL ) ?NIL :inner -> targetlist );
119119List * new_join_targetlist = NIL ;
120- List * qptlist = (( Plan * ) join ) -> targetlist ;
120+ List * qptlist = join -> targetlist ;
121121List * entry ;
122122
123123foreach (entry ,qptlist )
@@ -130,18 +130,16 @@ set_join_tlist_references(Join *join)
130130new_join_targetlist = lappend (new_join_targetlist ,
131131makeTargetEntry (xtl -> resdom ,joinexpr ));
132132}
133+ join -> targetlist = new_join_targetlist ;
133134
134- ((Plan * )join )-> targetlist = new_join_targetlist ;
135- if (outer != NULL )
136- set_tlist_references (outer );
137- if (inner != NULL )
138- set_tlist_references (inner );
135+ set_tlist_references (outer );
136+ set_tlist_references (inner );
139137}
140138
141139/*
142140 * set_nonamescan_tlist_references
143141 * Modifies the target list of a node that scans a noname relation (i.e., a
144- * sort orhash node) so that the varnos refer to the child noname.
142+ * sort ormaterialize node) so that the varnos refer to the child noname.
145143 *
146144 * 'nonamescan' is a seqscan node
147145 *
@@ -151,10 +149,13 @@ set_join_tlist_references(Join *join)
151149static void
152150set_nonamescan_tlist_references (SeqScan * nonamescan )
153151{
154- Noname * noname = (Noname * )(( Plan * ) nonamescan ) -> lefttree ;
152+ Noname * noname = (Noname * )nonamescan -> plan . lefttree ;
155153
156- ((Plan * )nonamescan )-> targetlist = tlist_noname_references (noname -> nonameid ,
157- ((Plan * )nonamescan )-> targetlist );
154+ nonamescan -> plan .targetlist = tlist_noname_references (noname -> nonameid ,
155+ nonamescan -> plan .targetlist );
156+ /* since we know child is a Noname, skip recursion through
157+ * set_tlist_references() and just get the job done
158+ */
158159set_noname_tlist_references (noname );
159160}
160161
@@ -164,21 +165,21 @@ set_nonamescan_tlist_references(SeqScan *nonamescan)
164165 * modified version of the target list of the node from which noname node
165166 * receives its tuples.
166167 *
167- * 'noname' is a noname (e.g., sort,hash ) plan node
168+ * 'noname' is a noname (e.g., sort,materialize ) plan node
168169 *
169170 * Returns nothing of interest, but modifies internal fields of nodes.
170171 *
171172 */
172173static void
173174set_noname_tlist_references (Noname * noname )
174175{
175- Plan * source = (( Plan * ) noname ) -> lefttree ;
176+ Plan * source = noname -> plan . lefttree ;
176177
177178if (source != NULL )
178179{
179180set_tlist_references (source );
180- (( Plan * ) noname ) -> targetlist = copy_vars ((( Plan * ) noname ) -> targetlist ,
181- ( source ) -> targetlist );
181+ noname -> plan . targetlist = copy_vars (noname -> plan . targetlist ,
182+ source -> targetlist );
182183}
183184else
184185elog (ERROR ,"calling set_noname_tlist_references with empty lefttree" );