aboutsummaryrefslogtreecommitdiff
path: root/src/backend/optimizer/plan/analyzejoins.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/optimizer/plan/analyzejoins.c')
-rw-r--r--src/backend/optimizer/plan/analyzejoins.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/src/backend/optimizer/plan/analyzejoins.c b/src/backend/optimizer/plan/analyzejoins.c
index 32695db367b..d19ff4138e5 100644
--- a/src/backend/optimizer/plan/analyzejoins.c
+++ b/src/backend/optimizer/plan/analyzejoins.c
@@ -96,17 +96,16 @@ restart:
/*
* We can delete this SpecialJoinInfo from the list too, since it's no
- * longer of interest.
+ * longer of interest. (Since we'll restart the foreach loop
+ * immediately, we don't bother with foreach_delete_current.)
*/
- root->join_info_list = list_delete_ptr(root->join_info_list, sjinfo);
+ root->join_info_list = list_delete_cell(root->join_info_list, lc);
/*
* Restart the scan. This is necessary to ensure we find all
* removable joins independently of ordering of the join_info_list
* (note that removal of attr_needed bits may make a join appear
- * removable that did not before). Also, since we just deleted the
- * current list cell, we'd have to have some kluge to continue the
- * list scan anyway.
+ * removable that did not before).
*/
goto restart;
}
@@ -316,7 +315,6 @@ remove_rel_from_query(PlannerInfo *root, int relid, Relids joinrelids)
List *joininfos;
Index rti;
ListCell *l;
- ListCell *nextl;
/*
* Mark the rel as "dead" to show it is no longer part of the join tree.
@@ -383,16 +381,15 @@ remove_rel_from_query(PlannerInfo *root, int relid, Relids joinrelids)
* remove or just update the PHV. There is no corresponding test in
* join_is_removable because it doesn't need to distinguish those cases.
*/
- for (l = list_head(root->placeholder_list); l != NULL; l = nextl)
+ foreach(l, root->placeholder_list)
{
PlaceHolderInfo *phinfo = (PlaceHolderInfo *) lfirst(l);
- nextl = lnext(l);
Assert(!bms_is_member(relid, phinfo->ph_lateral));
if (bms_is_subset(phinfo->ph_needed, joinrelids) &&
bms_is_member(relid, phinfo->ph_eval_at))
- root->placeholder_list = list_delete_ptr(root->placeholder_list,
- phinfo);
+ root->placeholder_list = foreach_delete_current(root->placeholder_list,
+ l);
else
{
phinfo->ph_eval_at = bms_del_member(phinfo->ph_eval_at, relid);
@@ -511,13 +508,11 @@ void
reduce_unique_semijoins(PlannerInfo *root)
{
ListCell *lc;
- ListCell *next;
/*
- * Scan the join_info_list to find semijoins. We can't use foreach
- * because we may delete the current cell.
+ * Scan the join_info_list to find semijoins.
*/
- for (lc = list_head(root->join_info_list); lc != NULL; lc = next)
+ foreach(lc, root->join_info_list)
{
SpecialJoinInfo *sjinfo = (SpecialJoinInfo *) lfirst(lc);
int innerrelid;
@@ -525,8 +520,6 @@ reduce_unique_semijoins(PlannerInfo *root)
Relids joinrelids;
List *restrictlist;
- next = lnext(lc);
-
/*
* Must be a non-delaying semijoin to a single baserel, else we aren't
* going to be able to do anything with it. (It's probably not
@@ -572,7 +565,7 @@ reduce_unique_semijoins(PlannerInfo *root)
continue;
/* OK, remove the SpecialJoinInfo from the list. */
- root->join_info_list = list_delete_ptr(root->join_info_list, sjinfo);
+ root->join_info_list = foreach_delete_current(root->join_info_list, lc);
}
}
@@ -897,7 +890,7 @@ query_is_distinct_for(Query *query, List *colnos, List *opids)
/* non-resjunk columns should have grouping clauses */
Assert(lg != NULL);
sgc = (SortGroupClause *) lfirst(lg);
- lg = lnext(lg);
+ lg = lnext(topop->groupClauses, lg);
opid = distinct_col_search(tle->resno, colnos, opids);
if (!OidIsValid(opid) ||