1 /*-------------------------------------------------------------------------
4 * JoinInfo node manipulation routines
6 * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
7 * Portions Copyright (c) 1994, Regents of the University of California
11 * $Header: /cvsroot/pgsql/src/backend/optimizer/util/joininfo.c,v 1.26 2000/02/06 03:27:33 tgl Exp $
13 *-------------------------------------------------------------------------
18 #include "optimizer/joininfo.h"
23 * Determines whether a node has already been created for a join
24 * between a set of join relations and the relation described by
27 * 'join_relids' is a list of relids corresponding to the join relation
28 * 'joininfo_list' is the list of joininfo nodes against which this is
31 * Returns the corresponding node in 'joininfo_list' if such a node
36 joininfo_member(List *join_relids, List *joininfo_list)
40 foreach(i, joininfo_list)
42 JoinInfo *joininfo = (JoinInfo *) lfirst(i);
44 if (sameseti(join_relids, joininfo->unjoined_relids))
53 * Find the joininfo node within a relation entry corresponding
54 * to a join between 'this_rel' and the relations in 'join_relids'.
55 * A new node is created and added to the relation entry's joininfo
56 * field if the desired one can't be found.
58 * Returns a joininfo node.
62 find_joininfo_node(RelOptInfo *this_rel, Relids join_relids)
64 JoinInfo *joininfo = joininfo_member(join_relids,
69 joininfo = makeNode(JoinInfo);
70 joininfo->unjoined_relids = join_relids;
71 joininfo->jinfo_restrictinfo = NIL;
72 this_rel->joininfo = lcons(joininfo, this_rel->joininfo);