Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
39c8dd66
Commit
39c8dd66
authored
14 years ago
by
Tom Lane
Browse files
Options
Downloads
Patches
Plain Diff
Invert and rename flag variable to improve code readability.
No change in functionality. Per discussion with Robert.
parent
7b464015
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/backend/optimizer/path/joinpath.c
+24
-23
24 additions, 23 deletions
src/backend/optimizer/path/joinpath.c
with
24 additions
and
23 deletions
src/backend/optimizer/path/joinpath.c
+
24
−
23
View file @
39c8dd66
...
@@ -42,7 +42,7 @@ static List *select_mergejoin_clauses(PlannerInfo *root,
...
@@ -42,7 +42,7 @@ static List *select_mergejoin_clauses(PlannerInfo *root,
RelOptInfo
*
innerrel
,
RelOptInfo
*
innerrel
,
List
*
restrictlist
,
List
*
restrictlist
,
JoinType
jointype
,
JoinType
jointype
,
bool
*
have_nonmergeable_clause
);
bool
*
mergejoin_allowed
);
/*
/*
...
@@ -78,7 +78,7 @@ add_paths_to_joinrel(PlannerInfo *root,
...
@@ -78,7 +78,7 @@ add_paths_to_joinrel(PlannerInfo *root,
List
*
restrictlist
)
List
*
restrictlist
)
{
{
List
*
mergeclause_list
=
NIL
;
List
*
mergeclause_list
=
NIL
;
bool
have_nonmergeable_clause
=
fals
e
;
bool
mergejoin_allowed
=
tru
e
;
/*
/*
* Find potential mergejoin clauses. We can skip this if we are not
* Find potential mergejoin clauses. We can skip this if we are not
...
@@ -93,13 +93,13 @@ add_paths_to_joinrel(PlannerInfo *root,
...
@@ -93,13 +93,13 @@ add_paths_to_joinrel(PlannerInfo *root,
innerrel
,
innerrel
,
restrictlist
,
restrictlist
,
jointype
,
jointype
,
&
have_nonmergeable_clause
);
&
mergejoin_allowed
);
/*
/*
* 1. Consider mergejoin paths where both relations must be explicitly
* 1. Consider mergejoin paths where both relations must be explicitly
* sorted. Skip this if we can't mergejoin.
* sorted. Skip this if we can't mergejoin.
*/
*/
if
(
!
have_nonmergeable_clause
)
if
(
mergejoin_allowed
)
sort_inner_and_outer
(
root
,
joinrel
,
outerrel
,
innerrel
,
sort_inner_and_outer
(
root
,
joinrel
,
outerrel
,
innerrel
,
restrictlist
,
mergeclause_list
,
jointype
,
sjinfo
);
restrictlist
,
mergeclause_list
,
jointype
,
sjinfo
);
...
@@ -108,9 +108,9 @@ add_paths_to_joinrel(PlannerInfo *root,
...
@@ -108,9 +108,9 @@ add_paths_to_joinrel(PlannerInfo *root,
* sorted. This includes both nestloops and mergejoins where the outer
* sorted. This includes both nestloops and mergejoins where the outer
* path is already ordered. Again, skip this if we can't mergejoin.
* path is already ordered. Again, skip this if we can't mergejoin.
* (That's okay because we know that nestloop can't handle right/full
* (That's okay because we know that nestloop can't handle right/full
* joins at all, so it wouldn't work in th
ose
cases either.)
* joins at all, so it wouldn't work in th
e prohibited
cases either.)
*/
*/
if
(
!
have_nonmergeable_clause
)
if
(
mergejoin_allowed
)
match_unsorted_outer
(
root
,
joinrel
,
outerrel
,
innerrel
,
match_unsorted_outer
(
root
,
joinrel
,
outerrel
,
innerrel
,
restrictlist
,
mergeclause_list
,
jointype
,
sjinfo
);
restrictlist
,
mergeclause_list
,
jointype
,
sjinfo
);
...
@@ -127,7 +127,7 @@ add_paths_to_joinrel(PlannerInfo *root,
...
@@ -127,7 +127,7 @@ add_paths_to_joinrel(PlannerInfo *root,
* those made by match_unsorted_outer when add_paths_to_joinrel() is
* those made by match_unsorted_outer when add_paths_to_joinrel() is
* invoked with the two rels given in the other order.
* invoked with the two rels given in the other order.
*/
*/
if
(
!
have_nonmergeable_clause
)
if
(
mergejoin_allowed
)
match_unsorted_inner
(
root
,
joinrel
,
outerrel
,
innerrel
,
match_unsorted_inner
(
root
,
joinrel
,
outerrel
,
innerrel
,
restrictlist
,
mergeclause_list
,
jointype
,
sjinfo
);
restrictlist
,
mergeclause_list
,
jointype
,
sjinfo
);
#endif
#endif
...
@@ -927,10 +927,14 @@ best_appendrel_indexscan(PlannerInfo *root, RelOptInfo *rel,
...
@@ -927,10 +927,14 @@ best_appendrel_indexscan(PlannerInfo *root, RelOptInfo *rel,
* Select mergejoin clauses that are usable for a particular join.
* Select mergejoin clauses that are usable for a particular join.
* Returns a list of RestrictInfo nodes for those clauses.
* Returns a list of RestrictInfo nodes for those clauses.
*
*
* *have_nonmergeable_clause is set TRUE if this is a right/full join and
* *mergejoin_allowed is normally set to TRUE, but it is set to FALSE if
* there are nonmergejoinable join clauses. The executor's mergejoin
* this is a right/full join and there are nonmergejoinable join clauses.
* machinery cannot handle such cases, so we have to avoid generating a
* The executor's mergejoin machinery cannot handle such cases, so we have
* mergejoin plan.
* to avoid generating a mergejoin plan. (Note that this flag does NOT
* consider whether there are actually any mergejoinable clauses. This is
* correct because in some cases we need to build a clauseless mergejoin.
* Simply returning NIL is therefore not enough to distinguish safe from
* unsafe cases.)
*
*
* We also mark each selected RestrictInfo to show which side is currently
* We also mark each selected RestrictInfo to show which side is currently
* being considered as outer. These are transient markings that are only
* being considered as outer. These are transient markings that are only
...
@@ -947,14 +951,13 @@ select_mergejoin_clauses(PlannerInfo *root,
...
@@ -947,14 +951,13 @@ select_mergejoin_clauses(PlannerInfo *root,
RelOptInfo
*
innerrel
,
RelOptInfo
*
innerrel
,
List
*
restrictlist
,
List
*
restrictlist
,
JoinType
jointype
,
JoinType
jointype
,
bool
*
have_nonmergeable_clause
)
bool
*
mergejoin_allowed
)
{
{
List
*
result_list
=
NIL
;
List
*
result_list
=
NIL
;
bool
isouterjoin
=
IS_OUTER_JOIN
(
jointype
);
bool
isouterjoin
=
IS_OUTER_JOIN
(
jointype
);
bool
have_nonmergeable_joinclause
=
false
;
ListCell
*
l
;
ListCell
*
l
;
*
have_nonmergeable_clause
=
false
;
foreach
(
l
,
restrictlist
)
foreach
(
l
,
restrictlist
)
{
{
RestrictInfo
*
restrictinfo
=
(
RestrictInfo
*
)
lfirst
(
l
);
RestrictInfo
*
restrictinfo
=
(
RestrictInfo
*
)
lfirst
(
l
);
...
@@ -962,7 +965,7 @@ select_mergejoin_clauses(PlannerInfo *root,
...
@@ -962,7 +965,7 @@ select_mergejoin_clauses(PlannerInfo *root,
/*
/*
* If processing an outer join, only use its own join clauses in the
* If processing an outer join, only use its own join clauses in the
* merge. For inner joins we can use pushed-down clauses too. (Note:
* merge. For inner joins we can use pushed-down clauses too. (Note:
* we don't set have_nonmergeable_clause here because pushed-down
* we don't set have_nonmergeable_
join
clause here because pushed-down
* clauses will become otherquals not joinquals.)
* clauses will become otherquals not joinquals.)
*/
*/
if
(
isouterjoin
&&
restrictinfo
->
is_pushed_down
)
if
(
isouterjoin
&&
restrictinfo
->
is_pushed_down
)
...
@@ -979,7 +982,7 @@ select_mergejoin_clauses(PlannerInfo *root,
...
@@ -979,7 +982,7 @@ select_mergejoin_clauses(PlannerInfo *root,
* FALSE.)
* FALSE.)
*/
*/
if
(
!
restrictinfo
->
clause
||
!
IsA
(
restrictinfo
->
clause
,
Const
))
if
(
!
restrictinfo
->
clause
||
!
IsA
(
restrictinfo
->
clause
,
Const
))
*
have_nonmergeable_clause
=
true
;
have_nonmergeable_
join
clause
=
true
;
continue
;
/* not mergejoinable */
continue
;
/* not mergejoinable */
}
}
...
@@ -988,7 +991,7 @@ select_mergejoin_clauses(PlannerInfo *root,
...
@@ -988,7 +991,7 @@ select_mergejoin_clauses(PlannerInfo *root,
*/
*/
if
(
!
clause_sides_match_join
(
restrictinfo
,
outerrel
,
innerrel
))
if
(
!
clause_sides_match_join
(
restrictinfo
,
outerrel
,
innerrel
))
{
{
*
have_nonmergeable_clause
=
true
;
have_nonmergeable_
join
clause
=
true
;
continue
;
/* no good for these input relations */
continue
;
/* no good for these input relations */
}
}
...
@@ -1017,7 +1020,7 @@ select_mergejoin_clauses(PlannerInfo *root,
...
@@ -1017,7 +1020,7 @@ select_mergejoin_clauses(PlannerInfo *root,
if
(
EC_MUST_BE_REDUNDANT
(
restrictinfo
->
left_ec
)
||
if
(
EC_MUST_BE_REDUNDANT
(
restrictinfo
->
left_ec
)
||
EC_MUST_BE_REDUNDANT
(
restrictinfo
->
right_ec
))
EC_MUST_BE_REDUNDANT
(
restrictinfo
->
right_ec
))
{
{
*
have_nonmergeable_clause
=
true
;
have_nonmergeable_
join
clause
=
true
;
continue
;
/* can't handle redundant eclasses */
continue
;
/* can't handle redundant eclasses */
}
}
...
@@ -1025,18 +1028,16 @@ select_mergejoin_clauses(PlannerInfo *root,
...
@@ -1025,18 +1028,16 @@ select_mergejoin_clauses(PlannerInfo *root,
}
}
/*
/*
* If it is not a right/full join then we don't need to insist on all the
* Report whether mergejoin is allowed (see comment at top of function).
* joinclauses being mergejoinable, so reset the flag. This simplifies
* the logic in add_paths_to_joinrel.
*/
*/
switch
(
jointype
)
switch
(
jointype
)
{
{
case
JOIN_RIGHT
:
case
JOIN_RIGHT
:
case
JOIN_FULL
:
case
JOIN_FULL
:
*
mergejoin_allowed
=
!
have_nonmergeable_joinclause
;
break
;
break
;
default:
default:
/* otherwise, it's OK to have nonmergeable join quals */
*
mergejoin_allowed
=
true
;
*
have_nonmergeable_clause
=
false
;
break
;
break
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment