8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $Header: /cvsroot/pgsql/src/backend/optimizer/util/relnode.c,v 1.39 2002/09/04 20:31:22 momjian Exp $
11
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/relnode.c,v 1.40 2002/10/12 22:24:49 tgl Exp $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
@@ -28,7 +28,8 @@ static List *new_join_tlist(List *tlist, int first_resdomno);
28
28
static List * build_joinrel_restrictlist (Query * root ,
29
29
RelOptInfo * joinrel ,
30
30
RelOptInfo * outer_rel ,
31
- RelOptInfo * inner_rel );
31
+ RelOptInfo * inner_rel ,
32
+ JoinType jointype );
32
33
static void build_joinrel_joinlist (RelOptInfo * joinrel ,
33
34
RelOptInfo * outer_rel ,
34
35
RelOptInfo * inner_rel );
@@ -334,7 +335,8 @@ build_join_rel(Query *root,
334
335
* restrictlist_ptr = build_joinrel_restrictlist (root ,
335
336
joinrel ,
336
337
outer_rel ,
337
- inner_rel );
338
+ inner_rel ,
339
+ jointype );
338
340
return joinrel ;
339
341
}
340
342
@@ -419,7 +421,8 @@ build_join_rel(Query *root,
419
421
restrictlist = build_joinrel_restrictlist (root ,
420
422
joinrel ,
421
423
outer_rel ,
422
- inner_rel );
424
+ inner_rel ,
425
+ jointype );
423
426
if (restrictlist_ptr )
424
427
* restrictlist_ptr = restrictlist ;
425
428
build_joinrel_joinlist (joinrel , outer_rel , inner_rel );
@@ -508,6 +511,7 @@ new_join_tlist(List *tlist,
508
511
* 'joinrel' is a join relation node
509
512
* 'outer_rel' and 'inner_rel' are a pair of relations that can be joined
510
513
* to form joinrel.
514
+ * 'jointype' is the type of join used.
511
515
*
512
516
* build_joinrel_restrictlist() returns a list of relevant restrictinfos,
513
517
* whereas build_joinrel_joinlist() stores its results in the joinrel's
@@ -522,7 +526,8 @@ static List *
522
526
build_joinrel_restrictlist (Query * root ,
523
527
RelOptInfo * joinrel ,
524
528
RelOptInfo * outer_rel ,
525
- RelOptInfo * inner_rel )
529
+ RelOptInfo * inner_rel ,
530
+ JoinType jointype )
526
531
{
527
532
List * result = NIL ;
528
533
List * rlist ;
@@ -553,6 +558,11 @@ build_joinrel_restrictlist(Query *root,
553
558
* one clause that checks equality between any set member on the left
554
559
* and any member on the right; by transitivity, all the rest are then
555
560
* equal.
561
+ *
562
+ * Weird special case: if we have two clauses that seem redundant
563
+ * except one is pushed down into an outer join and the other isn't,
564
+ * then they're not really redundant, because one constrains the
565
+ * joined rows after addition of null fill rows, and the other doesn't.
556
566
*/
557
567
foreach (item , rlist )
558
568
{
@@ -576,7 +586,9 @@ build_joinrel_restrictlist(Query *root,
576
586
577
587
if (oldrinfo -> mergejoinoperator != InvalidOid &&
578
588
rinfo -> left_pathkey == oldrinfo -> left_pathkey &&
579
- rinfo -> right_pathkey == oldrinfo -> right_pathkey )
589
+ rinfo -> right_pathkey == oldrinfo -> right_pathkey &&
590
+ (rinfo -> ispusheddown == oldrinfo -> ispusheddown ||
591
+ !IS_OUTER_JOIN (jointype )))
580
592
{
581
593
redundant = true;
582
594
break ;
0 commit comments