Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit39c8dd6

Browse files
committed
Invert and rename flag variable to improve code readability.
No change in functionality. Per discussion with Robert.
1 parent7b46401 commit39c8dd6

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

‎src/backend/optimizer/path/joinpath.c

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static List *select_mergejoin_clauses(PlannerInfo *root,
4242
RelOptInfo*innerrel,
4343
List*restrictlist,
4444
JoinTypejointype,
45-
bool*have_nonmergeable_clause);
45+
bool*mergejoin_allowed);
4646

4747

4848
/*
@@ -78,7 +78,7 @@ add_paths_to_joinrel(PlannerInfo *root,
7878
List*restrictlist)
7979
{
8080
List*mergeclause_list=NIL;
81-
boolhave_nonmergeable_clause=false;
81+
boolmergejoin_allowed=true;
8282

8383
/*
8484
* Find potential mergejoin clauses. We can skip this if we are not
@@ -93,13 +93,13 @@ add_paths_to_joinrel(PlannerInfo *root,
9393
innerrel,
9494
restrictlist,
9595
jointype,
96-
&have_nonmergeable_clause);
96+
&mergejoin_allowed);
9797

9898
/*
9999
* 1. Consider mergejoin paths where both relations must be explicitly
100100
* sorted. Skip this if we can't mergejoin.
101101
*/
102-
if (!have_nonmergeable_clause)
102+
if (mergejoin_allowed)
103103
sort_inner_and_outer(root,joinrel,outerrel,innerrel,
104104
restrictlist,mergeclause_list,jointype,sjinfo);
105105

@@ -108,9 +108,9 @@ add_paths_to_joinrel(PlannerInfo *root,
108108
* sorted. This includes both nestloops and mergejoins where the outer
109109
* path is already ordered. Again, skip this if we can't mergejoin.
110110
* (That's okay because we know that nestloop can't handle right/full
111-
* joins at all, so it wouldn't work inthose cases either.)
111+
* joins at all, so it wouldn't work inthe prohibited cases either.)
112112
*/
113-
if (!have_nonmergeable_clause)
113+
if (mergejoin_allowed)
114114
match_unsorted_outer(root,joinrel,outerrel,innerrel,
115115
restrictlist,mergeclause_list,jointype,sjinfo);
116116

@@ -127,7 +127,7 @@ add_paths_to_joinrel(PlannerInfo *root,
127127
* those made by match_unsorted_outer when add_paths_to_joinrel() is
128128
* invoked with the two rels given in the other order.
129129
*/
130-
if (!have_nonmergeable_clause)
130+
if (mergejoin_allowed)
131131
match_unsorted_inner(root,joinrel,outerrel,innerrel,
132132
restrictlist,mergeclause_list,jointype,sjinfo);
133133
#endif
@@ -927,10 +927,14 @@ best_appendrel_indexscan(PlannerInfo *root, RelOptInfo *rel,
927927
* Select mergejoin clauses that are usable for a particular join.
928928
* Returns a list of RestrictInfo nodes for those clauses.
929929
*
930-
* *have_nonmergeable_clause is set TRUE if this is a right/full join and
931-
* there are nonmergejoinable join clauses. The executor's mergejoin
932-
* machinery cannot handle such cases, so we have to avoid generating a
933-
* mergejoin plan.
930+
* *mergejoin_allowed is normally set to TRUE, but it is set to FALSE if
931+
* this is a right/full join and there are nonmergejoinable join clauses.
932+
* The executor's mergejoin machinery cannot handle such cases, so we have
933+
* to avoid generating a mergejoin plan. (Note that this flag does NOT
934+
* consider whether there are actually any mergejoinable clauses. This is
935+
* correct because in some cases we need to build a clauseless mergejoin.
936+
* Simply returning NIL is therefore not enough to distinguish safe from
937+
* unsafe cases.)
934938
*
935939
* We also mark each selected RestrictInfo to show which side is currently
936940
* being considered as outer. These are transient markings that are only
@@ -947,22 +951,21 @@ select_mergejoin_clauses(PlannerInfo *root,
947951
RelOptInfo*innerrel,
948952
List*restrictlist,
949953
JoinTypejointype,
950-
bool*have_nonmergeable_clause)
954+
bool*mergejoin_allowed)
951955
{
952956
List*result_list=NIL;
953957
boolisouterjoin=IS_OUTER_JOIN(jointype);
958+
boolhave_nonmergeable_joinclause= false;
954959
ListCell*l;
955960

956-
*have_nonmergeable_clause= false;
957-
958961
foreach(l,restrictlist)
959962
{
960963
RestrictInfo*restrictinfo= (RestrictInfo*)lfirst(l);
961964

962965
/*
963966
* If processing an outer join, only use its own join clauses in the
964967
* merge. For inner joins we can use pushed-down clauses too. (Note:
965-
* we don't sethave_nonmergeable_clause here because pushed-down
968+
* we don't sethave_nonmergeable_joinclause here because pushed-down
966969
* clauses will become otherquals not joinquals.)
967970
*/
968971
if (isouterjoin&&restrictinfo->is_pushed_down)
@@ -979,7 +982,7 @@ select_mergejoin_clauses(PlannerInfo *root,
979982
* FALSE.)
980983
*/
981984
if (!restrictinfo->clause|| !IsA(restrictinfo->clause,Const))
982-
*have_nonmergeable_clause= true;
985+
have_nonmergeable_joinclause= true;
983986
continue;/* not mergejoinable */
984987
}
985988

@@ -988,7 +991,7 @@ select_mergejoin_clauses(PlannerInfo *root,
988991
*/
989992
if (!clause_sides_match_join(restrictinfo,outerrel,innerrel))
990993
{
991-
*have_nonmergeable_clause= true;
994+
have_nonmergeable_joinclause= true;
992995
continue;/* no good for these input relations */
993996
}
994997

@@ -1017,26 +1020,24 @@ select_mergejoin_clauses(PlannerInfo *root,
10171020
if (EC_MUST_BE_REDUNDANT(restrictinfo->left_ec)||
10181021
EC_MUST_BE_REDUNDANT(restrictinfo->right_ec))
10191022
{
1020-
*have_nonmergeable_clause= true;
1023+
have_nonmergeable_joinclause= true;
10211024
continue;/* can't handle redundant eclasses */
10221025
}
10231026

10241027
result_list=lappend(result_list,restrictinfo);
10251028
}
10261029

10271030
/*
1028-
* If it is not a right/full join then we don't need to insist on all the
1029-
* joinclauses being mergejoinable, so reset the flag. This simplifies
1030-
* the logic in add_paths_to_joinrel.
1031+
* Report whether mergejoin is allowed (see comment at top of function).
10311032
*/
10321033
switch (jointype)
10331034
{
10341035
caseJOIN_RIGHT:
10351036
caseJOIN_FULL:
1037+
*mergejoin_allowed= !have_nonmergeable_joinclause;
10361038
break;
10371039
default:
1038-
/* otherwise, it's OK to have nonmergeable join quals */
1039-
*have_nonmergeable_clause= false;
1040+
*mergejoin_allowed= true;
10401041
break;
10411042
}
10421043

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp