* joininfo.c
* JoinInfo node manipulation routines
*
- * Copyright (c) 1994, Regents of the University of California
+ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/util/joininfo.c,v 1.21 1999/05/25 22:41:47 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/joininfo.c,v 1.28 2001/01/24 19:43:00 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
-#include "nodes/relation.h"
-#include "optimizer/internal.h"
#include "optimizer/joininfo.h"
-#include "optimizer/var.h"
-#include "optimizer/clauses.h"
+static JoinInfo *joininfo_member(List *join_relids, List *joininfo_list);
/*
* joininfo_member
* exists.
*
*/
-JoinInfo *
+static JoinInfo *
joininfo_member(List *join_relids, List *joininfo_list)
{
List *i;
{
JoinInfo *joininfo = (JoinInfo *) lfirst(i);
- if (same(join_relids, joininfo->unjoined_relids))
+ if (sameseti(join_relids, joininfo->unjoined_relids))
return joininfo;
}
return NULL;
/*
* find_joininfo_node
* Find the joininfo node within a relation entry corresponding
- * to a join between 'this_rel' and the relations in 'join_relids'. A
- * new node is created and added to the relation entry's joininfo
+ * to a join between 'this_rel' and the relations in 'join_relids'.
+ * A new node is created and added to the relation entry's joininfo
* field if the desired one can't be found.
*
* Returns a joininfo node.
joininfo = makeNode(JoinInfo);
joininfo->unjoined_relids = join_relids;
joininfo->jinfo_restrictinfo = NIL;
- joininfo->mergejoinable = false;
- joininfo->hashjoinable = false;
this_rel->joininfo = lcons(joininfo, this_rel->joininfo);
}
return joininfo;
}
-
-/*
- * other_join_clause_var
- * Determines whether a var node is contained within a joinclause
- * of the form(op var var).
- *
- * Returns the other var node in the joinclause if it is, nil if not.
- *
- */
-Var *
-other_join_clause_var(Var *var, Expr *clause)
-{
- Var *retval;
- Var *l,
- *r;
-
- retval = (Var *) NULL;
-
- if (var != NULL && is_joinable((Node *) clause))
- {
- l = (Var *) get_leftop(clause);
- r = (Var *) get_rightop(clause);
-
- if (equal(var, l))
- retval = r;
- else if (equal(var, r))
- retval = l;
- }
-
- return retval;
-}