mirror of
https://github.com/postgres/postgres.git
synced 2025-06-10 09:21:54 +03:00
Use lfirst_node() and linitial_node() where appropriate in planner.c.
There's no particular reason to target this module for the first wholesale application of these macros; but we gotta start somewhere. Ashutosh Bapat and Jeevan Chalke Discussion: https://postgr.es/m/CAFjFpRcNr3r=u0ni=7A4GD9NnHQVq+dkFafzqo2rS6zy=dt1eg@mail.gmail.com
This commit is contained in:
parent
153a49bb33
commit
6e427aa4e5
@ -411,7 +411,7 @@ standard_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
|
|||||||
forboth(lp, glob->subplans, lr, glob->subroots)
|
forboth(lp, glob->subplans, lr, glob->subroots)
|
||||||
{
|
{
|
||||||
Plan *subplan = (Plan *) lfirst(lp);
|
Plan *subplan = (Plan *) lfirst(lp);
|
||||||
PlannerInfo *subroot = (PlannerInfo *) lfirst(lr);
|
PlannerInfo *subroot = lfirst_node(PlannerInfo, lr);
|
||||||
|
|
||||||
SS_finalize_plan(subroot, subplan);
|
SS_finalize_plan(subroot, subplan);
|
||||||
}
|
}
|
||||||
@ -430,7 +430,7 @@ standard_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
|
|||||||
forboth(lp, glob->subplans, lr, glob->subroots)
|
forboth(lp, glob->subplans, lr, glob->subroots)
|
||||||
{
|
{
|
||||||
Plan *subplan = (Plan *) lfirst(lp);
|
Plan *subplan = (Plan *) lfirst(lp);
|
||||||
PlannerInfo *subroot = (PlannerInfo *) lfirst(lr);
|
PlannerInfo *subroot = lfirst_node(PlannerInfo, lr);
|
||||||
|
|
||||||
lfirst(lp) = set_plan_references(subroot, subplan);
|
lfirst(lp) = set_plan_references(subroot, subplan);
|
||||||
}
|
}
|
||||||
@ -586,7 +586,7 @@ subquery_planner(PlannerGlobal *glob, Query *parse,
|
|||||||
hasOuterJoins = false;
|
hasOuterJoins = false;
|
||||||
foreach(l, parse->rtable)
|
foreach(l, parse->rtable)
|
||||||
{
|
{
|
||||||
RangeTblEntry *rte = (RangeTblEntry *) lfirst(l);
|
RangeTblEntry *rte = lfirst_node(RangeTblEntry, l);
|
||||||
|
|
||||||
if (rte->rtekind == RTE_JOIN)
|
if (rte->rtekind == RTE_JOIN)
|
||||||
{
|
{
|
||||||
@ -643,7 +643,7 @@ subquery_planner(PlannerGlobal *glob, Query *parse,
|
|||||||
newWithCheckOptions = NIL;
|
newWithCheckOptions = NIL;
|
||||||
foreach(l, parse->withCheckOptions)
|
foreach(l, parse->withCheckOptions)
|
||||||
{
|
{
|
||||||
WithCheckOption *wco = (WithCheckOption *) lfirst(l);
|
WithCheckOption *wco = lfirst_node(WithCheckOption, l);
|
||||||
|
|
||||||
wco->qual = preprocess_expression(root, wco->qual,
|
wco->qual = preprocess_expression(root, wco->qual,
|
||||||
EXPRKIND_QUAL);
|
EXPRKIND_QUAL);
|
||||||
@ -663,7 +663,7 @@ subquery_planner(PlannerGlobal *glob, Query *parse,
|
|||||||
|
|
||||||
foreach(l, parse->windowClause)
|
foreach(l, parse->windowClause)
|
||||||
{
|
{
|
||||||
WindowClause *wc = (WindowClause *) lfirst(l);
|
WindowClause *wc = lfirst_node(WindowClause, l);
|
||||||
|
|
||||||
/* partitionClause/orderClause are sort/group expressions */
|
/* partitionClause/orderClause are sort/group expressions */
|
||||||
wc->startOffset = preprocess_expression(root, wc->startOffset,
|
wc->startOffset = preprocess_expression(root, wc->startOffset,
|
||||||
@ -705,7 +705,7 @@ subquery_planner(PlannerGlobal *glob, Query *parse,
|
|||||||
/* Also need to preprocess expressions within RTEs */
|
/* Also need to preprocess expressions within RTEs */
|
||||||
foreach(l, parse->rtable)
|
foreach(l, parse->rtable)
|
||||||
{
|
{
|
||||||
RangeTblEntry *rte = (RangeTblEntry *) lfirst(l);
|
RangeTblEntry *rte = lfirst_node(RangeTblEntry, l);
|
||||||
int kind;
|
int kind;
|
||||||
ListCell *lcsq;
|
ListCell *lcsq;
|
||||||
|
|
||||||
@ -1080,7 +1080,7 @@ inheritance_planner(PlannerInfo *root)
|
|||||||
rti = 1;
|
rti = 1;
|
||||||
foreach(lc, parse->rtable)
|
foreach(lc, parse->rtable)
|
||||||
{
|
{
|
||||||
RangeTblEntry *rte = (RangeTblEntry *) lfirst(lc);
|
RangeTblEntry *rte = lfirst_node(RangeTblEntry, lc);
|
||||||
|
|
||||||
if (rte->rtekind == RTE_SUBQUERY)
|
if (rte->rtekind == RTE_SUBQUERY)
|
||||||
subqueryRTindexes = bms_add_member(subqueryRTindexes, rti);
|
subqueryRTindexes = bms_add_member(subqueryRTindexes, rti);
|
||||||
@ -1102,7 +1102,7 @@ inheritance_planner(PlannerInfo *root)
|
|||||||
{
|
{
|
||||||
foreach(lc, root->append_rel_list)
|
foreach(lc, root->append_rel_list)
|
||||||
{
|
{
|
||||||
AppendRelInfo *appinfo = (AppendRelInfo *) lfirst(lc);
|
AppendRelInfo *appinfo = lfirst_node(AppendRelInfo, lc);
|
||||||
|
|
||||||
if (bms_is_member(appinfo->parent_relid, subqueryRTindexes) ||
|
if (bms_is_member(appinfo->parent_relid, subqueryRTindexes) ||
|
||||||
bms_is_member(appinfo->child_relid, subqueryRTindexes) ||
|
bms_is_member(appinfo->child_relid, subqueryRTindexes) ||
|
||||||
@ -1130,7 +1130,7 @@ inheritance_planner(PlannerInfo *root)
|
|||||||
*/
|
*/
|
||||||
foreach(lc, root->append_rel_list)
|
foreach(lc, root->append_rel_list)
|
||||||
{
|
{
|
||||||
AppendRelInfo *appinfo = (AppendRelInfo *) lfirst(lc);
|
AppendRelInfo *appinfo = lfirst_node(AppendRelInfo, lc);
|
||||||
PlannerInfo *subroot;
|
PlannerInfo *subroot;
|
||||||
RangeTblEntry *child_rte;
|
RangeTblEntry *child_rte;
|
||||||
RelOptInfo *sub_final_rel;
|
RelOptInfo *sub_final_rel;
|
||||||
@ -1192,7 +1192,7 @@ inheritance_planner(PlannerInfo *root)
|
|||||||
subroot->append_rel_list = NIL;
|
subroot->append_rel_list = NIL;
|
||||||
foreach(lc2, root->append_rel_list)
|
foreach(lc2, root->append_rel_list)
|
||||||
{
|
{
|
||||||
AppendRelInfo *appinfo2 = (AppendRelInfo *) lfirst(lc2);
|
AppendRelInfo *appinfo2 = lfirst_node(AppendRelInfo, lc2);
|
||||||
|
|
||||||
if (bms_is_member(appinfo2->child_relid, modifiableARIindexes))
|
if (bms_is_member(appinfo2->child_relid, modifiableARIindexes))
|
||||||
appinfo2 = copyObject(appinfo2);
|
appinfo2 = copyObject(appinfo2);
|
||||||
@ -1227,7 +1227,7 @@ inheritance_planner(PlannerInfo *root)
|
|||||||
rti = 1;
|
rti = 1;
|
||||||
foreach(lr, parse->rtable)
|
foreach(lr, parse->rtable)
|
||||||
{
|
{
|
||||||
RangeTblEntry *rte = (RangeTblEntry *) lfirst(lr);
|
RangeTblEntry *rte = lfirst_node(RangeTblEntry, lr);
|
||||||
|
|
||||||
if (bms_is_member(rti, subqueryRTindexes))
|
if (bms_is_member(rti, subqueryRTindexes))
|
||||||
{
|
{
|
||||||
@ -1249,7 +1249,7 @@ inheritance_planner(PlannerInfo *root)
|
|||||||
|
|
||||||
foreach(lc2, subroot->append_rel_list)
|
foreach(lc2, subroot->append_rel_list)
|
||||||
{
|
{
|
||||||
AppendRelInfo *appinfo2 = (AppendRelInfo *) lfirst(lc2);
|
AppendRelInfo *appinfo2 = lfirst_node(AppendRelInfo, lc2);
|
||||||
|
|
||||||
if (bms_is_member(appinfo2->child_relid,
|
if (bms_is_member(appinfo2->child_relid,
|
||||||
modifiableARIindexes))
|
modifiableARIindexes))
|
||||||
@ -1407,7 +1407,7 @@ inheritance_planner(PlannerInfo *root)
|
|||||||
rti = 1;
|
rti = 1;
|
||||||
foreach(lc, final_rtable)
|
foreach(lc, final_rtable)
|
||||||
{
|
{
|
||||||
RangeTblEntry *rte = (RangeTblEntry *) lfirst(lc);
|
RangeTblEntry *rte = lfirst_node(RangeTblEntry, lc);
|
||||||
|
|
||||||
root->simple_rte_array[rti++] = rte;
|
root->simple_rte_array[rti++] = rte;
|
||||||
}
|
}
|
||||||
@ -1556,8 +1556,8 @@ grouping_planner(PlannerInfo *root, bool inheritance_update,
|
|||||||
/*------
|
/*------
|
||||||
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
translator: %s is a SQL row locking clause such as FOR UPDATE */
|
||||||
errmsg("%s is not allowed with UNION/INTERSECT/EXCEPT",
|
errmsg("%s is not allowed with UNION/INTERSECT/EXCEPT",
|
||||||
LCS_asString(((RowMarkClause *)
|
LCS_asString(linitial_node(RowMarkClause,
|
||||||
linitial(parse->rowMarks))->strength))));
|
parse->rowMarks)->strength))));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calculate pathkeys that represent result ordering requirements
|
* Calculate pathkeys that represent result ordering requirements
|
||||||
@ -1687,7 +1687,7 @@ grouping_planner(PlannerInfo *root, bool inheritance_update,
|
|||||||
qp_extra.tlist = tlist;
|
qp_extra.tlist = tlist;
|
||||||
qp_extra.activeWindows = activeWindows;
|
qp_extra.activeWindows = activeWindows;
|
||||||
qp_extra.groupClause = (gset_data
|
qp_extra.groupClause = (gset_data
|
||||||
? (gset_data->rollups ? ((RollupData *) linitial(gset_data->rollups))->groupClause : NIL)
|
? (gset_data->rollups ? linitial_node(RollupData, gset_data->rollups)->groupClause : NIL)
|
||||||
: parse->groupClause);
|
: parse->groupClause);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1757,25 +1757,25 @@ grouping_planner(PlannerInfo *root, bool inheritance_update,
|
|||||||
split_pathtarget_at_srfs(root, final_target, sort_input_target,
|
split_pathtarget_at_srfs(root, final_target, sort_input_target,
|
||||||
&final_targets,
|
&final_targets,
|
||||||
&final_targets_contain_srfs);
|
&final_targets_contain_srfs);
|
||||||
final_target = (PathTarget *) linitial(final_targets);
|
final_target = linitial_node(PathTarget, final_targets);
|
||||||
Assert(!linitial_int(final_targets_contain_srfs));
|
Assert(!linitial_int(final_targets_contain_srfs));
|
||||||
/* likewise for sort_input_target vs. grouping_target */
|
/* likewise for sort_input_target vs. grouping_target */
|
||||||
split_pathtarget_at_srfs(root, sort_input_target, grouping_target,
|
split_pathtarget_at_srfs(root, sort_input_target, grouping_target,
|
||||||
&sort_input_targets,
|
&sort_input_targets,
|
||||||
&sort_input_targets_contain_srfs);
|
&sort_input_targets_contain_srfs);
|
||||||
sort_input_target = (PathTarget *) linitial(sort_input_targets);
|
sort_input_target = linitial_node(PathTarget, sort_input_targets);
|
||||||
Assert(!linitial_int(sort_input_targets_contain_srfs));
|
Assert(!linitial_int(sort_input_targets_contain_srfs));
|
||||||
/* likewise for grouping_target vs. scanjoin_target */
|
/* likewise for grouping_target vs. scanjoin_target */
|
||||||
split_pathtarget_at_srfs(root, grouping_target, scanjoin_target,
|
split_pathtarget_at_srfs(root, grouping_target, scanjoin_target,
|
||||||
&grouping_targets,
|
&grouping_targets,
|
||||||
&grouping_targets_contain_srfs);
|
&grouping_targets_contain_srfs);
|
||||||
grouping_target = (PathTarget *) linitial(grouping_targets);
|
grouping_target = linitial_node(PathTarget, grouping_targets);
|
||||||
Assert(!linitial_int(grouping_targets_contain_srfs));
|
Assert(!linitial_int(grouping_targets_contain_srfs));
|
||||||
/* scanjoin_target will not have any SRFs precomputed for it */
|
/* scanjoin_target will not have any SRFs precomputed for it */
|
||||||
split_pathtarget_at_srfs(root, scanjoin_target, NULL,
|
split_pathtarget_at_srfs(root, scanjoin_target, NULL,
|
||||||
&scanjoin_targets,
|
&scanjoin_targets,
|
||||||
&scanjoin_targets_contain_srfs);
|
&scanjoin_targets_contain_srfs);
|
||||||
scanjoin_target = (PathTarget *) linitial(scanjoin_targets);
|
scanjoin_target = linitial_node(PathTarget, scanjoin_targets);
|
||||||
Assert(!linitial_int(scanjoin_targets_contain_srfs));
|
Assert(!linitial_int(scanjoin_targets_contain_srfs));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2106,7 +2106,7 @@ preprocess_grouping_sets(PlannerInfo *root)
|
|||||||
|
|
||||||
foreach(lc, parse->groupClause)
|
foreach(lc, parse->groupClause)
|
||||||
{
|
{
|
||||||
SortGroupClause *gc = lfirst(lc);
|
SortGroupClause *gc = lfirst_node(SortGroupClause, lc);
|
||||||
Index ref = gc->tleSortGroupRef;
|
Index ref = gc->tleSortGroupRef;
|
||||||
|
|
||||||
if (ref > maxref)
|
if (ref > maxref)
|
||||||
@ -2135,7 +2135,7 @@ preprocess_grouping_sets(PlannerInfo *root)
|
|||||||
|
|
||||||
foreach(lc, parse->groupingSets)
|
foreach(lc, parse->groupingSets)
|
||||||
{
|
{
|
||||||
List *gset = lfirst(lc);
|
List *gset = (List *) lfirst(lc);
|
||||||
|
|
||||||
if (bms_overlap_list(gd->unsortable_refs, gset))
|
if (bms_overlap_list(gd->unsortable_refs, gset))
|
||||||
{
|
{
|
||||||
@ -2194,7 +2194,7 @@ preprocess_grouping_sets(PlannerInfo *root)
|
|||||||
/*
|
/*
|
||||||
* Get the initial (and therefore largest) grouping set.
|
* Get the initial (and therefore largest) grouping set.
|
||||||
*/
|
*/
|
||||||
gs = linitial(current_sets);
|
gs = linitial_node(GroupingSetData, current_sets);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Order the groupClause appropriately. If the first grouping set is
|
* Order the groupClause appropriately. If the first grouping set is
|
||||||
@ -2269,7 +2269,7 @@ remap_to_groupclause_idx(List *groupClause,
|
|||||||
|
|
||||||
foreach(lc, groupClause)
|
foreach(lc, groupClause)
|
||||||
{
|
{
|
||||||
SortGroupClause *gc = lfirst(lc);
|
SortGroupClause *gc = lfirst_node(SortGroupClause, lc);
|
||||||
|
|
||||||
tleref_to_colnum_map[gc->tleSortGroupRef] = ref++;
|
tleref_to_colnum_map[gc->tleSortGroupRef] = ref++;
|
||||||
}
|
}
|
||||||
@ -2278,7 +2278,7 @@ remap_to_groupclause_idx(List *groupClause,
|
|||||||
{
|
{
|
||||||
List *set = NIL;
|
List *set = NIL;
|
||||||
ListCell *lc2;
|
ListCell *lc2;
|
||||||
GroupingSetData *gs = lfirst(lc);
|
GroupingSetData *gs = lfirst_node(GroupingSetData, lc);
|
||||||
|
|
||||||
foreach(lc2, gs->set)
|
foreach(lc2, gs->set)
|
||||||
{
|
{
|
||||||
@ -2344,8 +2344,8 @@ preprocess_rowmarks(PlannerInfo *root)
|
|||||||
* CTIDs invalid. This is also checked at parse time, but that's
|
* CTIDs invalid. This is also checked at parse time, but that's
|
||||||
* insufficient because of rule substitution, query pullup, etc.
|
* insufficient because of rule substitution, query pullup, etc.
|
||||||
*/
|
*/
|
||||||
CheckSelectLocking(parse, ((RowMarkClause *)
|
CheckSelectLocking(parse, linitial_node(RowMarkClause,
|
||||||
linitial(parse->rowMarks))->strength);
|
parse->rowMarks)->strength);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2373,7 +2373,7 @@ preprocess_rowmarks(PlannerInfo *root)
|
|||||||
prowmarks = NIL;
|
prowmarks = NIL;
|
||||||
foreach(l, parse->rowMarks)
|
foreach(l, parse->rowMarks)
|
||||||
{
|
{
|
||||||
RowMarkClause *rc = (RowMarkClause *) lfirst(l);
|
RowMarkClause *rc = lfirst_node(RowMarkClause, l);
|
||||||
RangeTblEntry *rte = rt_fetch(rc->rti, parse->rtable);
|
RangeTblEntry *rte = rt_fetch(rc->rti, parse->rtable);
|
||||||
PlanRowMark *newrc;
|
PlanRowMark *newrc;
|
||||||
|
|
||||||
@ -2413,7 +2413,7 @@ preprocess_rowmarks(PlannerInfo *root)
|
|||||||
i = 0;
|
i = 0;
|
||||||
foreach(l, parse->rtable)
|
foreach(l, parse->rtable)
|
||||||
{
|
{
|
||||||
RangeTblEntry *rte = (RangeTblEntry *) lfirst(l);
|
RangeTblEntry *rte = lfirst_node(RangeTblEntry, l);
|
||||||
PlanRowMark *newrc;
|
PlanRowMark *newrc;
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
@ -2772,7 +2772,7 @@ remove_useless_groupby_columns(PlannerInfo *root)
|
|||||||
(list_length(parse->rtable) + 1));
|
(list_length(parse->rtable) + 1));
|
||||||
foreach(lc, parse->groupClause)
|
foreach(lc, parse->groupClause)
|
||||||
{
|
{
|
||||||
SortGroupClause *sgc = (SortGroupClause *) lfirst(lc);
|
SortGroupClause *sgc = lfirst_node(SortGroupClause, lc);
|
||||||
TargetEntry *tle = get_sortgroupclause_tle(sgc, parse->targetList);
|
TargetEntry *tle = get_sortgroupclause_tle(sgc, parse->targetList);
|
||||||
Var *var = (Var *) tle->expr;
|
Var *var = (Var *) tle->expr;
|
||||||
|
|
||||||
@ -2805,7 +2805,7 @@ remove_useless_groupby_columns(PlannerInfo *root)
|
|||||||
relid = 0;
|
relid = 0;
|
||||||
foreach(lc, parse->rtable)
|
foreach(lc, parse->rtable)
|
||||||
{
|
{
|
||||||
RangeTblEntry *rte = (RangeTblEntry *) lfirst(lc);
|
RangeTblEntry *rte = lfirst_node(RangeTblEntry, lc);
|
||||||
Bitmapset *relattnos;
|
Bitmapset *relattnos;
|
||||||
Bitmapset *pkattnos;
|
Bitmapset *pkattnos;
|
||||||
Oid constraintOid;
|
Oid constraintOid;
|
||||||
@ -2863,7 +2863,7 @@ remove_useless_groupby_columns(PlannerInfo *root)
|
|||||||
|
|
||||||
foreach(lc, parse->groupClause)
|
foreach(lc, parse->groupClause)
|
||||||
{
|
{
|
||||||
SortGroupClause *sgc = (SortGroupClause *) lfirst(lc);
|
SortGroupClause *sgc = lfirst_node(SortGroupClause, lc);
|
||||||
TargetEntry *tle = get_sortgroupclause_tle(sgc, parse->targetList);
|
TargetEntry *tle = get_sortgroupclause_tle(sgc, parse->targetList);
|
||||||
Var *var = (Var *) tle->expr;
|
Var *var = (Var *) tle->expr;
|
||||||
|
|
||||||
@ -2938,11 +2938,11 @@ preprocess_groupclause(PlannerInfo *root, List *force)
|
|||||||
*/
|
*/
|
||||||
foreach(sl, parse->sortClause)
|
foreach(sl, parse->sortClause)
|
||||||
{
|
{
|
||||||
SortGroupClause *sc = (SortGroupClause *) lfirst(sl);
|
SortGroupClause *sc = lfirst_node(SortGroupClause, sl);
|
||||||
|
|
||||||
foreach(gl, parse->groupClause)
|
foreach(gl, parse->groupClause)
|
||||||
{
|
{
|
||||||
SortGroupClause *gc = (SortGroupClause *) lfirst(gl);
|
SortGroupClause *gc = lfirst_node(SortGroupClause, gl);
|
||||||
|
|
||||||
if (equal(gc, sc))
|
if (equal(gc, sc))
|
||||||
{
|
{
|
||||||
@ -2971,7 +2971,7 @@ preprocess_groupclause(PlannerInfo *root, List *force)
|
|||||||
*/
|
*/
|
||||||
foreach(gl, parse->groupClause)
|
foreach(gl, parse->groupClause)
|
||||||
{
|
{
|
||||||
SortGroupClause *gc = (SortGroupClause *) lfirst(gl);
|
SortGroupClause *gc = lfirst_node(SortGroupClause, gl);
|
||||||
|
|
||||||
if (list_member_ptr(new_groupclause, gc))
|
if (list_member_ptr(new_groupclause, gc))
|
||||||
continue; /* it matched an ORDER BY item */
|
continue; /* it matched an ORDER BY item */
|
||||||
@ -3071,7 +3071,7 @@ extract_rollup_sets(List *groupingSets)
|
|||||||
|
|
||||||
for_each_cell(lc, lc1)
|
for_each_cell(lc, lc1)
|
||||||
{
|
{
|
||||||
List *candidate = lfirst(lc);
|
List *candidate = (List *) lfirst(lc);
|
||||||
Bitmapset *candidate_set = NULL;
|
Bitmapset *candidate_set = NULL;
|
||||||
ListCell *lc2;
|
ListCell *lc2;
|
||||||
int dup_of = 0;
|
int dup_of = 0;
|
||||||
@ -3228,7 +3228,7 @@ reorder_grouping_sets(List *groupingsets, List *sortclause)
|
|||||||
|
|
||||||
foreach(lc, groupingsets)
|
foreach(lc, groupingsets)
|
||||||
{
|
{
|
||||||
List *candidate = lfirst(lc);
|
List *candidate = (List *) lfirst(lc);
|
||||||
List *new_elems = list_difference_int(candidate, previous);
|
List *new_elems = list_difference_int(candidate, previous);
|
||||||
GroupingSetData *gs = makeNode(GroupingSetData);
|
GroupingSetData *gs = makeNode(GroupingSetData);
|
||||||
|
|
||||||
@ -3296,7 +3296,7 @@ standard_qp_callback(PlannerInfo *root, void *extra)
|
|||||||
/* We consider only the first (bottom) window in pathkeys logic */
|
/* We consider only the first (bottom) window in pathkeys logic */
|
||||||
if (activeWindows != NIL)
|
if (activeWindows != NIL)
|
||||||
{
|
{
|
||||||
WindowClause *wc = (WindowClause *) linitial(activeWindows);
|
WindowClause *wc = linitial_node(WindowClause, activeWindows);
|
||||||
|
|
||||||
root->window_pathkeys = make_pathkeys_for_window(root,
|
root->window_pathkeys = make_pathkeys_for_window(root,
|
||||||
wc,
|
wc,
|
||||||
@ -3384,7 +3384,7 @@ get_number_of_groups(PlannerInfo *root,
|
|||||||
|
|
||||||
foreach(lc, gd->rollups)
|
foreach(lc, gd->rollups)
|
||||||
{
|
{
|
||||||
RollupData *rollup = lfirst(lc);
|
RollupData *rollup = lfirst_node(RollupData, lc);
|
||||||
ListCell *lc;
|
ListCell *lc;
|
||||||
|
|
||||||
groupExprs = get_sortgrouplist_exprs(rollup->groupClause,
|
groupExprs = get_sortgrouplist_exprs(rollup->groupClause,
|
||||||
@ -3395,7 +3395,7 @@ get_number_of_groups(PlannerInfo *root,
|
|||||||
forboth(lc, rollup->gsets, lc2, rollup->gsets_data)
|
forboth(lc, rollup->gsets, lc2, rollup->gsets_data)
|
||||||
{
|
{
|
||||||
List *gset = (List *) lfirst(lc);
|
List *gset = (List *) lfirst(lc);
|
||||||
GroupingSetData *gs = lfirst(lc2);
|
GroupingSetData *gs = lfirst_node(GroupingSetData, lc2);
|
||||||
double numGroups = estimate_num_groups(root,
|
double numGroups = estimate_num_groups(root,
|
||||||
groupExprs,
|
groupExprs,
|
||||||
path_rows,
|
path_rows,
|
||||||
@ -3420,7 +3420,7 @@ get_number_of_groups(PlannerInfo *root,
|
|||||||
forboth(lc, gd->hash_sets_idx, lc2, gd->unsortable_sets)
|
forboth(lc, gd->hash_sets_idx, lc2, gd->unsortable_sets)
|
||||||
{
|
{
|
||||||
List *gset = (List *) lfirst(lc);
|
List *gset = (List *) lfirst(lc);
|
||||||
GroupingSetData *gs = lfirst(lc2);
|
GroupingSetData *gs = lfirst_node(GroupingSetData, lc2);
|
||||||
double numGroups = estimate_num_groups(root,
|
double numGroups = estimate_num_groups(root,
|
||||||
groupExprs,
|
groupExprs,
|
||||||
path_rows,
|
path_rows,
|
||||||
@ -4194,7 +4194,7 @@ consider_groupingsets_paths(PlannerInfo *root,
|
|||||||
|
|
||||||
if (pathkeys_contained_in(root->group_pathkeys, path->pathkeys))
|
if (pathkeys_contained_in(root->group_pathkeys, path->pathkeys))
|
||||||
{
|
{
|
||||||
unhashed_rollup = lfirst(l_start);
|
unhashed_rollup = lfirst_node(RollupData, l_start);
|
||||||
exclude_groups = unhashed_rollup->numGroups;
|
exclude_groups = unhashed_rollup->numGroups;
|
||||||
l_start = lnext(l_start);
|
l_start = lnext(l_start);
|
||||||
}
|
}
|
||||||
@ -4219,7 +4219,7 @@ consider_groupingsets_paths(PlannerInfo *root,
|
|||||||
|
|
||||||
for_each_cell(lc, l_start)
|
for_each_cell(lc, l_start)
|
||||||
{
|
{
|
||||||
RollupData *rollup = lfirst(lc);
|
RollupData *rollup = lfirst_node(RollupData, lc);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we find an unhashable rollup that's not been skipped by the
|
* If we find an unhashable rollup that's not been skipped by the
|
||||||
@ -4239,7 +4239,7 @@ consider_groupingsets_paths(PlannerInfo *root,
|
|||||||
}
|
}
|
||||||
foreach(lc, sets_data)
|
foreach(lc, sets_data)
|
||||||
{
|
{
|
||||||
GroupingSetData *gs = lfirst(lc);
|
GroupingSetData *gs = lfirst_node(GroupingSetData, lc);
|
||||||
List *gset = gs->set;
|
List *gset = gs->set;
|
||||||
RollupData *rollup;
|
RollupData *rollup;
|
||||||
|
|
||||||
@ -4381,7 +4381,7 @@ consider_groupingsets_paths(PlannerInfo *root,
|
|||||||
i = 0;
|
i = 0;
|
||||||
for_each_cell(lc, lnext(list_head(gd->rollups)))
|
for_each_cell(lc, lnext(list_head(gd->rollups)))
|
||||||
{
|
{
|
||||||
RollupData *rollup = lfirst(lc);
|
RollupData *rollup = lfirst_node(RollupData, lc);
|
||||||
|
|
||||||
if (rollup->hashable)
|
if (rollup->hashable)
|
||||||
{
|
{
|
||||||
@ -4415,7 +4415,7 @@ consider_groupingsets_paths(PlannerInfo *root,
|
|||||||
i = 0;
|
i = 0;
|
||||||
for_each_cell(lc, lnext(list_head(gd->rollups)))
|
for_each_cell(lc, lnext(list_head(gd->rollups)))
|
||||||
{
|
{
|
||||||
RollupData *rollup = lfirst(lc);
|
RollupData *rollup = lfirst_node(RollupData, lc);
|
||||||
|
|
||||||
if (rollup->hashable)
|
if (rollup->hashable)
|
||||||
{
|
{
|
||||||
@ -4437,7 +4437,7 @@ consider_groupingsets_paths(PlannerInfo *root,
|
|||||||
|
|
||||||
foreach(lc, hash_sets)
|
foreach(lc, hash_sets)
|
||||||
{
|
{
|
||||||
GroupingSetData *gs = lfirst(lc);
|
GroupingSetData *gs = lfirst_node(GroupingSetData, lc);
|
||||||
RollupData *rollup = makeNode(RollupData);
|
RollupData *rollup = makeNode(RollupData);
|
||||||
|
|
||||||
Assert(gs->set != NIL);
|
Assert(gs->set != NIL);
|
||||||
@ -4616,7 +4616,7 @@ create_one_window_path(PlannerInfo *root,
|
|||||||
|
|
||||||
foreach(l, activeWindows)
|
foreach(l, activeWindows)
|
||||||
{
|
{
|
||||||
WindowClause *wc = (WindowClause *) lfirst(l);
|
WindowClause *wc = lfirst_node(WindowClause, l);
|
||||||
List *window_pathkeys;
|
List *window_pathkeys;
|
||||||
|
|
||||||
window_pathkeys = make_pathkeys_for_window(root,
|
window_pathkeys = make_pathkeys_for_window(root,
|
||||||
@ -5280,7 +5280,7 @@ postprocess_setop_tlist(List *new_tlist, List *orig_tlist)
|
|||||||
|
|
||||||
foreach(l, new_tlist)
|
foreach(l, new_tlist)
|
||||||
{
|
{
|
||||||
TargetEntry *new_tle = (TargetEntry *) lfirst(l);
|
TargetEntry *new_tle = lfirst_node(TargetEntry, l);
|
||||||
TargetEntry *orig_tle;
|
TargetEntry *orig_tle;
|
||||||
|
|
||||||
/* ignore resjunk columns in setop result */
|
/* ignore resjunk columns in setop result */
|
||||||
@ -5288,7 +5288,7 @@ postprocess_setop_tlist(List *new_tlist, List *orig_tlist)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
Assert(orig_tlist_item != NULL);
|
Assert(orig_tlist_item != NULL);
|
||||||
orig_tle = (TargetEntry *) lfirst(orig_tlist_item);
|
orig_tle = lfirst_node(TargetEntry, orig_tlist_item);
|
||||||
orig_tlist_item = lnext(orig_tlist_item);
|
orig_tlist_item = lnext(orig_tlist_item);
|
||||||
if (orig_tle->resjunk) /* should not happen */
|
if (orig_tle->resjunk) /* should not happen */
|
||||||
elog(ERROR, "resjunk output columns are not implemented");
|
elog(ERROR, "resjunk output columns are not implemented");
|
||||||
@ -5316,7 +5316,7 @@ select_active_windows(PlannerInfo *root, WindowFuncLists *wflists)
|
|||||||
actives = NIL;
|
actives = NIL;
|
||||||
foreach(lc, root->parse->windowClause)
|
foreach(lc, root->parse->windowClause)
|
||||||
{
|
{
|
||||||
WindowClause *wc = (WindowClause *) lfirst(lc);
|
WindowClause *wc = lfirst_node(WindowClause, lc);
|
||||||
|
|
||||||
/* It's only active if wflists shows some related WindowFuncs */
|
/* It's only active if wflists shows some related WindowFuncs */
|
||||||
Assert(wc->winref <= wflists->maxWinRef);
|
Assert(wc->winref <= wflists->maxWinRef);
|
||||||
@ -5339,7 +5339,7 @@ select_active_windows(PlannerInfo *root, WindowFuncLists *wflists)
|
|||||||
result = NIL;
|
result = NIL;
|
||||||
while (actives != NIL)
|
while (actives != NIL)
|
||||||
{
|
{
|
||||||
WindowClause *wc = (WindowClause *) linitial(actives);
|
WindowClause *wc = linitial_node(WindowClause, actives);
|
||||||
ListCell *prev;
|
ListCell *prev;
|
||||||
ListCell *next;
|
ListCell *next;
|
||||||
|
|
||||||
@ -5351,7 +5351,7 @@ select_active_windows(PlannerInfo *root, WindowFuncLists *wflists)
|
|||||||
prev = NULL;
|
prev = NULL;
|
||||||
for (lc = list_head(actives); lc; lc = next)
|
for (lc = list_head(actives); lc; lc = next)
|
||||||
{
|
{
|
||||||
WindowClause *wc2 = (WindowClause *) lfirst(lc);
|
WindowClause *wc2 = lfirst_node(WindowClause, lc);
|
||||||
|
|
||||||
next = lnext(lc);
|
next = lnext(lc);
|
||||||
/* framing options are NOT to be compared here! */
|
/* framing options are NOT to be compared here! */
|
||||||
@ -5424,18 +5424,18 @@ make_window_input_target(PlannerInfo *root,
|
|||||||
sgrefs = NULL;
|
sgrefs = NULL;
|
||||||
foreach(lc, activeWindows)
|
foreach(lc, activeWindows)
|
||||||
{
|
{
|
||||||
WindowClause *wc = (WindowClause *) lfirst(lc);
|
WindowClause *wc = lfirst_node(WindowClause, lc);
|
||||||
ListCell *lc2;
|
ListCell *lc2;
|
||||||
|
|
||||||
foreach(lc2, wc->partitionClause)
|
foreach(lc2, wc->partitionClause)
|
||||||
{
|
{
|
||||||
SortGroupClause *sortcl = (SortGroupClause *) lfirst(lc2);
|
SortGroupClause *sortcl = lfirst_node(SortGroupClause, lc2);
|
||||||
|
|
||||||
sgrefs = bms_add_member(sgrefs, sortcl->tleSortGroupRef);
|
sgrefs = bms_add_member(sgrefs, sortcl->tleSortGroupRef);
|
||||||
}
|
}
|
||||||
foreach(lc2, wc->orderClause)
|
foreach(lc2, wc->orderClause)
|
||||||
{
|
{
|
||||||
SortGroupClause *sortcl = (SortGroupClause *) lfirst(lc2);
|
SortGroupClause *sortcl = lfirst_node(SortGroupClause, lc2);
|
||||||
|
|
||||||
sgrefs = bms_add_member(sgrefs, sortcl->tleSortGroupRef);
|
sgrefs = bms_add_member(sgrefs, sortcl->tleSortGroupRef);
|
||||||
}
|
}
|
||||||
@ -5444,7 +5444,7 @@ make_window_input_target(PlannerInfo *root,
|
|||||||
/* Add in sortgroupref numbers of GROUP BY clauses, too */
|
/* Add in sortgroupref numbers of GROUP BY clauses, too */
|
||||||
foreach(lc, parse->groupClause)
|
foreach(lc, parse->groupClause)
|
||||||
{
|
{
|
||||||
SortGroupClause *grpcl = (SortGroupClause *) lfirst(lc);
|
SortGroupClause *grpcl = lfirst_node(SortGroupClause, lc);
|
||||||
|
|
||||||
sgrefs = bms_add_member(sgrefs, grpcl->tleSortGroupRef);
|
sgrefs = bms_add_member(sgrefs, grpcl->tleSortGroupRef);
|
||||||
}
|
}
|
||||||
@ -5864,7 +5864,7 @@ adjust_paths_for_srfs(PlannerInfo *root, RelOptInfo *rel,
|
|||||||
Assert(subpath->param_info == NULL);
|
Assert(subpath->param_info == NULL);
|
||||||
forboth(lc1, targets, lc2, targets_contain_srfs)
|
forboth(lc1, targets, lc2, targets_contain_srfs)
|
||||||
{
|
{
|
||||||
PathTarget *thistarget = (PathTarget *) lfirst(lc1);
|
PathTarget *thistarget = lfirst_node(PathTarget, lc1);
|
||||||
bool contains_srfs = (bool) lfirst_int(lc2);
|
bool contains_srfs = (bool) lfirst_int(lc2);
|
||||||
|
|
||||||
/* If this level doesn't contain SRFs, do regular projection */
|
/* If this level doesn't contain SRFs, do regular projection */
|
||||||
@ -5897,7 +5897,7 @@ adjust_paths_for_srfs(PlannerInfo *root, RelOptInfo *rel,
|
|||||||
Assert(subpath->param_info == NULL);
|
Assert(subpath->param_info == NULL);
|
||||||
forboth(lc1, targets, lc2, targets_contain_srfs)
|
forboth(lc1, targets, lc2, targets_contain_srfs)
|
||||||
{
|
{
|
||||||
PathTarget *thistarget = (PathTarget *) lfirst(lc1);
|
PathTarget *thistarget = lfirst_node(PathTarget, lc1);
|
||||||
bool contains_srfs = (bool) lfirst_int(lc2);
|
bool contains_srfs = (bool) lfirst_int(lc2);
|
||||||
|
|
||||||
/* If this level doesn't contain SRFs, do regular projection */
|
/* If this level doesn't contain SRFs, do regular projection */
|
||||||
@ -6023,7 +6023,7 @@ plan_cluster_use_sort(Oid tableOid, Oid indexOid)
|
|||||||
indexInfo = NULL;
|
indexInfo = NULL;
|
||||||
foreach(lc, rel->indexlist)
|
foreach(lc, rel->indexlist)
|
||||||
{
|
{
|
||||||
indexInfo = (IndexOptInfo *) lfirst(lc);
|
indexInfo = lfirst_node(IndexOptInfo, lc);
|
||||||
if (indexInfo->indexoid == indexOid)
|
if (indexInfo->indexoid == indexOid)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -6086,7 +6086,7 @@ get_partitioned_child_rels(PlannerInfo *root, Index rti)
|
|||||||
|
|
||||||
foreach(l, root->pcinfo_list)
|
foreach(l, root->pcinfo_list)
|
||||||
{
|
{
|
||||||
PartitionedChildRelInfo *pc = lfirst(l);
|
PartitionedChildRelInfo *pc = lfirst_node(PartitionedChildRelInfo, l);
|
||||||
|
|
||||||
if (pc->parent_relid == rti)
|
if (pc->parent_relid == rti)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user