Rename same() to sameseti() to have a slightly less generic name. Move
nonoverlap_sets() and is_subset() to list.c, where they should have lived to begin with, and rename to nonoverlap_setsi and is_subseti since they only work on integer lists.
This commit is contained in:
parent
418b270020
commit
81fc1d5edb
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/list.c,v 1.28 2000/01/26 05:56:31 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/list.c,v 1.29 2000/02/06 03:27:32 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* XXX a few of the following functions are duplicated to handle
|
||||
@ -264,34 +264,32 @@ freeList(List *list)
|
||||
}
|
||||
|
||||
/*
|
||||
* same
|
||||
* sameseti
|
||||
*
|
||||
* Returns t if two lists contain the same elements
|
||||
* Returns t if two integer lists contain the same elements
|
||||
* (but unlike equal(), they need not be in the same order)
|
||||
*
|
||||
*
|
||||
* XXX should be called samei() --- only good for IntList -ay
|
||||
* Caution: this routine could be fooled if list1 contains
|
||||
* duplicate elements. It is intended to be used on lists
|
||||
* containing only nonduplicate elements, eg Relids lists.
|
||||
*/
|
||||
bool
|
||||
same(List *l1, List *l2)
|
||||
sameseti(List *list1, List *list2)
|
||||
{
|
||||
List *temp;
|
||||
|
||||
if (l1 == NIL)
|
||||
return l2 == NIL;
|
||||
if (l2 == NIL)
|
||||
return l1 == NIL;
|
||||
if (length(l1) == length(l2))
|
||||
if (list1 == NIL)
|
||||
return list2 == NIL;
|
||||
if (list2 == NIL)
|
||||
return false;
|
||||
if (length(list1) != length(list2))
|
||||
return false;
|
||||
foreach(temp, list1)
|
||||
{
|
||||
foreach(temp, l1)
|
||||
{
|
||||
if (!intMember(lfirsti(temp), l2))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
if (!intMember(lfirsti(temp), list2))
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -519,3 +517,39 @@ set_differencei(List *l1, List *l2)
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return t if two integer lists have no members in common.
|
||||
*/
|
||||
bool
|
||||
nonoverlap_setsi(List *list1, List *list2)
|
||||
{
|
||||
List *x;
|
||||
|
||||
foreach(x, list1)
|
||||
{
|
||||
int e = lfirsti(x);
|
||||
|
||||
if (intMember(e, list2))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return t if all members of integer list list1 appear in list2.
|
||||
*/
|
||||
bool
|
||||
is_subseti(List *list1, List *list2)
|
||||
{
|
||||
List *x;
|
||||
|
||||
foreach(x, list1)
|
||||
{
|
||||
int e = lfirsti(x);
|
||||
|
||||
if (!intMember(e, list2))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.49 2000/01/26 05:56:34 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.50 2000/02/06 03:27:32 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -181,7 +181,7 @@ best_innerjoin(List *join_paths, Relids outer_relids)
|
||||
* outer_relids in order to use this inner path, because those
|
||||
* rels are used in the index join quals of this inner path.
|
||||
*/
|
||||
if (is_subset(((IndexPath *) path)->joinrelids, outer_relids) &&
|
||||
if (is_subseti(((IndexPath *) path)->joinrelids, outer_relids) &&
|
||||
(cheapest == NULL ||
|
||||
path_is_cheaper(path, cheapest)))
|
||||
cheapest = path;
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.41 2000/01/26 05:56:34 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.42 2000/02/06 03:27:32 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -144,8 +144,8 @@ make_rels_by_clause_joins(Query *root, RelOptInfo *old_rel,
|
||||
RelOptInfo *join_rel = lfirst(r);
|
||||
|
||||
Assert(length(join_rel->relids) > 1);
|
||||
if (is_subset(unjoined_relids, join_rel->relids) &&
|
||||
nonoverlap_sets(old_rel->relids, join_rel->relids))
|
||||
if (is_subseti(unjoined_relids, join_rel->relids) &&
|
||||
nonoverlap_setsi(old_rel->relids, join_rel->relids))
|
||||
{
|
||||
joined_rel = make_join_rel(old_rel, join_rel);
|
||||
join_list = lappend(join_list, joined_rel);
|
||||
@ -175,7 +175,7 @@ make_rels_by_clauseless_joins(RelOptInfo *old_rel, List *inner_rels)
|
||||
{
|
||||
RelOptInfo *inner_rel = (RelOptInfo *) lfirst(i);
|
||||
|
||||
if (nonoverlap_sets(inner_rel->relids, old_rel->relids))
|
||||
if (nonoverlap_setsi(inner_rel->relids, old_rel->relids))
|
||||
{
|
||||
join_list = lappend(join_list,
|
||||
make_join_rel(old_rel, inner_rel));
|
||||
@ -404,39 +404,3 @@ get_cheapest_complete_rel(List *join_rel_list)
|
||||
|
||||
return final_rel;
|
||||
}
|
||||
|
||||
/*
|
||||
* Subset-inclusion tests on integer lists.
|
||||
*
|
||||
* XXX these probably ought to be in nodes/list.c or some such place.
|
||||
*/
|
||||
|
||||
bool
|
||||
nonoverlap_sets(List *s1, List *s2)
|
||||
{
|
||||
List *x;
|
||||
|
||||
foreach(x, s1)
|
||||
{
|
||||
int e = lfirsti(x);
|
||||
|
||||
if (intMember(e, s2))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
is_subset(List *s1, List *s2)
|
||||
{
|
||||
List *x;
|
||||
|
||||
foreach(x, s1)
|
||||
{
|
||||
int e = lfirsti(x);
|
||||
|
||||
if (!intMember(e, s2))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/prune.c,v 1.45 2000/01/26 05:56:34 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/prune.c,v 1.46 2000/02/06 03:27:32 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -67,7 +67,7 @@ merge_rel_with_same_relids(RelOptInfo *rel, List *unmerged_rels)
|
||||
{
|
||||
RelOptInfo *unmerged_rel = (RelOptInfo *) lfirst(i);
|
||||
|
||||
if (same(rel->relids, unmerged_rel->relids))
|
||||
if (sameseti(rel->relids, unmerged_rel->relids))
|
||||
{
|
||||
/*
|
||||
* These rels are for the same set of base relations,
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/joininfo.c,v 1.25 2000/01/26 05:56:40 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/joininfo.c,v 1.26 2000/02/06 03:27:33 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -41,7 +41,7 @@ joininfo_member(List *join_relids, List *joininfo_list)
|
||||
{
|
||||
JoinInfo *joininfo = (JoinInfo *) lfirst(i);
|
||||
|
||||
if (same(join_relids, joininfo->unjoined_relids))
|
||||
if (sameseti(join_relids, joininfo->unjoined_relids))
|
||||
return joininfo;
|
||||
}
|
||||
return NULL;
|
||||
|
@ -8,13 +8,12 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/relnode.c,v 1.21 2000/01/26 05:56:40 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/relnode.c,v 1.22 2000/02/06 03:27:33 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#include "postgres.h"
|
||||
|
||||
|
||||
#include "optimizer/internal.h"
|
||||
#include "optimizer/pathnode.h"
|
||||
#include "optimizer/plancat.h"
|
||||
@ -97,17 +96,14 @@ get_join_rel(Query *root, Relids relid)
|
||||
RelOptInfo *
|
||||
rel_member(Relids relids, List *rels)
|
||||
{
|
||||
if (relids != NIL && rels != NIL)
|
||||
List *temp;
|
||||
|
||||
foreach(temp, rels)
|
||||
{
|
||||
List *temp;
|
||||
RelOptInfo *rel = (RelOptInfo *) lfirst(temp);
|
||||
|
||||
foreach(temp, rels)
|
||||
{
|
||||
RelOptInfo *rel = (RelOptInfo *) lfirst(temp);
|
||||
|
||||
if (same(rel->relids, relids))
|
||||
return rel;
|
||||
}
|
||||
if (sameseti(rel->relids, relids))
|
||||
return rel;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: pg_list.h,v 1.14 2000/01/26 05:58:16 momjian Exp $
|
||||
* $Id: pg_list.h,v 1.15 2000/02/06 03:27:35 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -106,7 +106,10 @@ extern List *set_difference(List *list1, List *list2);
|
||||
extern List *set_differencei(List *list1, List *list2);
|
||||
extern List *LispUnion(List *list1, List *list2);
|
||||
extern List *LispUnioni(List *list1, List *list2);
|
||||
extern bool same(List *list1, List *list2);
|
||||
|
||||
extern bool sameseti(List *list1, List *list2);
|
||||
extern bool nonoverlap_setsi(List *list1, List *list2);
|
||||
extern bool is_subseti(List *list1, List *list2);
|
||||
|
||||
extern void freeList(List *list);
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: paths.h,v 1.40 2000/02/05 18:26:07 tgl Exp $
|
||||
* $Id: paths.h,v 1.41 2000/02/06 03:27:35 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -100,8 +100,6 @@ extern List *make_rels_by_clause_joins(Query *root, RelOptInfo *old_rel,
|
||||
extern List *make_rels_by_clauseless_joins(RelOptInfo *old_rel,
|
||||
List *inner_rels);
|
||||
extern RelOptInfo *get_cheapest_complete_rel(List *join_rel_list);
|
||||
extern bool nonoverlap_sets(List *s1, List *s2);
|
||||
extern bool is_subset(List *s1, List *s2);
|
||||
|
||||
/*
|
||||
* prune.c
|
||||
|
Loading…
x
Reference in New Issue
Block a user