7
7
*
8
8
*
9
9
* IDENTIFICATION
10
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/predmig.c,v 1.16 1999/02/1206:43:31 momjian Exp $
10
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/predmig.c,v 1.17 1999/02/1217:24:50 momjian Exp $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
53
53
* (not a join) iff it has
54
54
* a non-NULL cinfo field */
55
55
56
- static void xfunc_predmig (NestPath pathnode ,Stream streamroot ,
56
+ static void xfunc_predmig (JoinPath pathnode ,Stream streamroot ,
57
57
Stream laststream ,bool * progressp );
58
58
static bool xfunc_series_llel (Stream stream );
59
59
static bool xfunc_llel_chains (Stream root ,Stream bottom );
60
60
static Stream xfunc_complete_stream (Stream stream );
61
61
static bool xfunc_prdmig_pullup (Stream origstream ,Stream pullme ,
62
- NestPath joinpath );
62
+ JoinPath joinpath );
63
63
static void xfunc_form_groups (Stream root ,Stream bottom );
64
64
static void xfunc_free_stream (Stream root );
65
65
static Stream xfunc_add_clauses (Stream current );
@@ -91,8 +91,8 @@ xfunc_do_predmig(Path root)
91
91
do
92
92
{
93
93
progress = false;
94
- Assert (IsA (root ,NestPath ));
95
- xfunc_predmig ((NestPath )root , (Stream )NULL , (Stream )NULL ,
94
+ Assert (IsA (root ,JoinPath ));
95
+ xfunc_predmig ((JoinPath )root , (Stream )NULL , (Stream )NULL ,
96
96
& progress );
97
97
if (changed && progress )
98
98
elog (DEBUG ,"Needed to do a second round of predmig!\n" );
@@ -111,7 +111,7 @@ xfunc_do_predmig(Path root)
111
111
** Destructively modifies the join tree (via predicate pullup).
112
112
*/
113
113
static void
114
- xfunc_predmig (NestPath pathnode ,/* root of the join tree */
114
+ xfunc_predmig (JoinPath pathnode ,/* root of the join tree */
115
115
Stream streamroot ,
116
116
Stream laststream ,/* for recursive calls -- these are the
117
117
* root of the stream under construction,
@@ -161,11 +161,11 @@ xfunc_predmig(NestPath pathnode,/* root of the join tree */
161
161
else
162
162
{
163
163
/* visit left child */
164
- xfunc_predmig ((NestPath )get_outerjoinpath (pathnode ),
164
+ xfunc_predmig ((JoinPath )get_outerjoinpath (pathnode ),
165
165
streamroot ,newstream ,progressp );
166
166
167
167
/* visit right child */
168
- xfunc_predmig ((NestPath )get_innerjoinpath (pathnode ),
168
+ xfunc_predmig ((JoinPath )get_innerjoinpath (pathnode ),
169
169
streamroot ,newstream ,progressp );
170
170
}
171
171
@@ -257,7 +257,7 @@ xfunc_llel_chains(Stream root, Stream bottom)
257
257
*/
258
258
Assert (xfunc_num_relids (pathstream )> xfunc_num_relids (tmpstream ));
259
259
progress = xfunc_prdmig_pullup (origstream ,tmpstream ,
260
- (NestPath )get_pathptr (pathstream ));
260
+ (JoinPath )get_pathptr (pathstream ));
261
261
}
262
262
if (get_downstream (tmpstream ))
263
263
pathstream = (Stream )xfunc_get_downjoin ((Stream )get_downstream (tmpstream ));
@@ -304,14 +304,14 @@ xfunc_complete_stream(Stream stream)
304
304
305
305
/*
306
306
** xfunc_prdmig_pullup
307
- ** pullup a clause in a path above joinpath. Since theNestPath tree
307
+ ** pullup a clause in a path above joinpath. Since theJoinPath tree
308
308
** doesn't have upward pointers, it's difficult to deal with.Thus we
309
309
** require the original stream, which maintains pointers to all the path
310
310
** nodes.We use the original stream to find out what joins are
311
311
** above the clause.
312
312
*/
313
313
static bool
314
- xfunc_prdmig_pullup (Stream origstream ,Stream pullme ,NestPath joinpath )
314
+ xfunc_prdmig_pullup (Stream origstream ,Stream pullme ,JoinPath joinpath )
315
315
{
316
316
RestrictInfo restrictinfo = get_cinfo (pullme );
317
317
bool progress = false;
@@ -333,7 +333,7 @@ xfunc_prdmig_pullup(Stream origstream, Stream pullme, NestPath joinpath)
333
333
/* pull up this node as far as it should go */
334
334
for (upjoin = (Stream )xfunc_get_upjoin (orignode );
335
335
upjoin != (Stream )NULL
336
- && (NestPath )get_pathptr ((Stream )xfunc_get_downjoin (upjoin ))
336
+ && (JoinPath )get_pathptr ((Stream )xfunc_get_downjoin (upjoin ))
337
337
!= joinpath ;
338
338
upjoin = (Stream )xfunc_get_upjoin (upjoin ))
339
339
{
@@ -342,12 +342,12 @@ xfunc_prdmig_pullup(Stream origstream, Stream pullme, NestPath joinpath)
342
342
#endif
343
343
/* move clause up in path */
344
344
if (get_pathptr ((Stream )get_downstream (upjoin ))
345
- == (pathPtr )get_outerjoinpath ((NestPath )get_pathptr (upjoin )))
345
+ == (pathPtr )get_outerjoinpath ((JoinPath )get_pathptr (upjoin )))
346
346
whichchild = OUTER ;
347
347
else
348
348
whichchild = INNER ;
349
349
restrictinfo = xfunc_pullup ((Path )get_pathptr ((Stream )get_downstream (upjoin )),
350
- (NestPath )get_pathptr (upjoin ),
350
+ (JoinPath )get_pathptr (upjoin ),
351
351
restrictinfo ,
352
352
whichchild ,
353
353
get_clausetype (orignode ));
@@ -366,21 +366,21 @@ xfunc_prdmig_pullup(Stream origstream, Stream pullme, NestPath joinpath)
366
366
temp = (Stream )get_downstream (temp ))
367
367
set_pathptr
368
368
(temp , (pathPtr )
369
- get_outerjoinpath ((NestPath )get_pathptr (upjoin )));
369
+ get_outerjoinpath ((JoinPath )get_pathptr (upjoin )));
370
370
set_pathptr
371
371
(temp ,
372
- (pathPtr )get_outerjoinpath ((NestPath )get_pathptr (upjoin )));
372
+ (pathPtr )get_outerjoinpath ((JoinPath )get_pathptr (upjoin )));
373
373
}
374
374
else
375
375
{
376
376
for (temp = (Stream )get_downstream (upjoin );is_clause (temp );
377
377
temp = (Stream )get_downstream (temp ))
378
378
set_pathptr
379
379
(temp , (pathPtr )
380
- get_innerjoinpath ((NestPath )get_pathptr (upjoin )));
380
+ get_innerjoinpath ((JoinPath )get_pathptr (upjoin )));
381
381
set_pathptr
382
382
(temp , (pathPtr )
383
- get_innerjoinpath ((NestPath )get_pathptr (upjoin )));
383
+ get_innerjoinpath ((JoinPath )get_pathptr (upjoin )));
384
384
}
385
385
progress = true;
386
386
}
@@ -425,14 +425,14 @@ xfunc_form_groups(Query *queryInfo, Stream root, Stream bottom)
425
425
if (!is_clause (temp ))
426
426
{
427
427
if (get_pathptr ((Stream )get_downstream (temp ))
428
- == (pathPtr )get_outerjoinpath ((NestPath )get_pathptr (temp )))
428
+ == (pathPtr )get_outerjoinpath ((JoinPath )get_pathptr (temp )))
429
429
whichchild = OUTER ;
430
430
else
431
431
whichchild = INNER ;
432
432
set_groupcost (temp ,
433
- xfunc_join_expense ((NestPath )get_pathptr (temp ),
433
+ xfunc_join_expense ((JoinPath )get_pathptr (temp ),
434
434
whichchild ));
435
- if (primjoin = xfunc_primary_join ((NestPath )get_pathptr (temp )))
435
+ if (primjoin = xfunc_primary_join ((JoinPath )get_pathptr (temp )))
436
436
{
437
437
set_groupsel (temp ,
438
438
compute_clause_selec (queryInfo ,
@@ -529,10 +529,10 @@ xfunc_add_clauses(Stream current)
529
529
}
530
530
531
531
/* and add in the join clauses */
532
- if (IsA (get_pathptr (current ),NestPath ))
532
+ if (IsA (get_pathptr (current ),JoinPath ))
533
533
{
534
- primjoin = xfunc_primary_join ((NestPath )get_pathptr (current ));
535
- foreach (temp ,get_pathrestrictinfo ((NestPath )get_pathptr (current )))
534
+ primjoin = xfunc_primary_join ((JoinPath )get_pathptr (current ));
535
+ foreach (temp ,get_pathrestrictinfo ((JoinPath )get_pathptr (current )))
536
536
{
537
537
if (!equal (get_clause ((RestrictInfo )lfirst (temp )),primjoin ))
538
538
topnode = xfunc_streaminsert ((RestrictInfo )lfirst (temp ),topnode ,
@@ -615,11 +615,11 @@ xfunc_streaminsert(RestrictInfo restrictinfo,
615
615
static int
616
616
xfunc_num_relids (Stream node )
617
617
{
618
- if (!node || !IsA (get_pathptr (node ),NestPath ))
618
+ if (!node || !IsA (get_pathptr (node ),JoinPath ))
619
619
return 0 ;
620
620
else
621
621
return (length
622
- (get_relids (get_parent ((NestPath )get_pathptr (node )))));
622
+ (get_relids (get_parent ((JoinPath )get_pathptr (node )))));
623
623
}
624
624
625
625
/*