aboutsummaryrefslogtreecommitdiff
path: root/src/backend/optimizer/path
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-07-28 22:27:02 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-07-28 22:27:02 +0000
commit5d27bf20b482ca7d1bd206da49bd6495d783bc71 (patch)
treec2c18f7f6569033a0ca48ac9f8596602e66b1e03 /src/backend/optimizer/path
parentef85f5fabc0626228f7f75cbc6d3a93626691ea4 (diff)
downloadpostgresql-5d27bf20b482ca7d1bd206da49bd6495d783bc71.tar.gz
postgresql-5d27bf20b482ca7d1bd206da49bd6495d783bc71.zip
Make use of new list primitives list_append_unique and list_concat_unique
where applicable.
Diffstat (limited to 'src/backend/optimizer/path')
-rw-r--r--src/backend/optimizer/path/joinrels.c24
-rw-r--r--src/backend/optimizer/path/pathkeys.c13
2 files changed, 11 insertions, 26 deletions
diff --git a/src/backend/optimizer/path/joinrels.c b/src/backend/optimizer/path/joinrels.c
index f51e492eca1..f4f2d779b0a 100644
--- a/src/backend/optimizer/path/joinrels.c
+++ b/src/backend/optimizer/path/joinrels.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/path/joinrels.c,v 1.74 2005/06/09 04:18:59 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/path/joinrels.c,v 1.75 2005/07/28 22:27:00 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -44,7 +44,6 @@ make_rels_by_joins(PlannerInfo *root, int level, List **joinrels)
{
List *result_rels = NIL;
List *new_rels;
- ListCell *nr;
ListCell *r;
int k;
@@ -121,13 +120,7 @@ make_rels_by_joins(PlannerInfo *root, int level, List **joinrels)
* for subsequent passes, do not enter the same RelOptInfo into
* our output list multiple times.
*/
- foreach(nr, new_rels)
- {
- RelOptInfo *jrel = (RelOptInfo *) lfirst(nr);
-
- if (!list_member_ptr(result_rels, jrel))
- result_rels = lcons(jrel, result_rels);
- }
+ result_rels = list_concat_unique_ptr(result_rels, new_rels);
}
/*
@@ -182,8 +175,9 @@ make_rels_by_joins(PlannerInfo *root, int level, List **joinrels)
jrel = make_join_rel(root, old_rel, new_rel,
JOIN_INNER);
/* Avoid making duplicate entries ... */
- if (jrel && !list_member_ptr(result_rels, jrel))
- result_rels = lcons(jrel, result_rels);
+ if (jrel)
+ result_rels = list_append_unique_ptr(result_rels,
+ jrel);
}
}
}
@@ -224,13 +218,7 @@ make_rels_by_joins(PlannerInfo *root, int level, List **joinrels)
old_rel,
other_rels);
- foreach(nr, new_rels)
- {
- RelOptInfo *jrel = (RelOptInfo *) lfirst(nr);
-
- if (!list_member_ptr(result_rels, jrel))
- result_rels = lcons(jrel, result_rels);
- }
+ result_rels = list_concat_unique_ptr(result_rels, new_rels);
}
/*----------
diff --git a/src/backend/optimizer/path/pathkeys.c b/src/backend/optimizer/path/pathkeys.c
index 26ccfd9297e..3e4bcffe2e8 100644
--- a/src/backend/optimizer/path/pathkeys.c
+++ b/src/backend/optimizer/path/pathkeys.c
@@ -11,7 +11,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/path/pathkeys.c,v 1.70 2005/07/03 18:26:32 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/path/pathkeys.c,v 1.71 2005/07/28 22:27:00 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -163,7 +163,7 @@ add_equijoined_keys(PlannerInfo *root, RestrictInfo *restrictinfo)
newset = list_make2(item1, item2);
/* Found a set to merge into our new set */
- newset = list_union(newset, curset);
+ newset = list_concat_unique(newset, curset);
/*
* Remove old set from equi_key_list.
@@ -714,8 +714,7 @@ canonicalize_pathkeys(PlannerInfo *root, List *pathkeys)
* canonicalized the keys, so that equivalent-key knowledge is
* used when deciding if an item is redundant.
*/
- if (!list_member_ptr(new_pathkeys, cpathkey))
- new_pathkeys = lappend(new_pathkeys, cpathkey);
+ new_pathkeys = list_append_unique_ptr(new_pathkeys, cpathkey);
}
return new_pathkeys;
}
@@ -1024,8 +1023,7 @@ build_index_pathkeys(PlannerInfo *root,
* Eliminate redundant ordering info; could happen if query is
* such that index keys are equijoined...
*/
- if (!list_member_ptr(retval, cpathkey))
- retval = lappend(retval, cpathkey);
+ retval = list_append_unique_ptr(retval, cpathkey);
indexkeys++;
ordering++;
@@ -1467,8 +1465,7 @@ make_pathkeys_for_mergeclauses(PlannerInfo *root,
* pathkey, a simple ptrMember test is sufficient to detect
* redundant keys.
*/
- if (!list_member_ptr(pathkeys, pathkey))
- pathkeys = lappend(pathkeys, pathkey);
+ pathkeys = list_append_unique_ptr(pathkeys, pathkey);
}
return pathkeys;