*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.66 2001/10/25 05:49:32 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.67 2001/11/11 19:18:54 tgl Exp $
*
*-------------------------------------------------------------------------
*/
List *mergeclause_list,
JoinType jointype)
{
+ bool useallclauses;
List *all_pathkeys;
List *i;
+ /*
+ * If we are doing a right or full join, we must use *all* the
+ * mergeclauses as join clauses, else we will not have a valid plan.
+ */
+ switch (jointype)
+ {
+ case JOIN_INNER:
+ case JOIN_LEFT:
+ useallclauses = false;
+ break;
+ case JOIN_RIGHT:
+ case JOIN_FULL:
+ useallclauses = true;
+ break;
+ default:
+ elog(ERROR, "sort_inner_and_outer: unexpected join type %d",
+ (int) jointype);
+ useallclauses = false; /* keep compiler quiet */
+ break;
+ }
+
/*
* Each possible ordering of the available mergejoin clauses will
* generate a differently-sorted result path at essentially the same
mergeclause_list);
Assert(cur_mergeclauses != NIL);
+ /* Forget it if can't use all the clauses in right/full join */
+ if (useallclauses &&
+ length(cur_mergeclauses) != length(mergeclause_list))
+ continue;
+
/*
* Build sort pathkeys for both sides.
*