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

Commit2453196

Browse files
committed
Move clause_sides_match_join() into restrictinfo.h
Two near-identical copies of clause_sides_match_join() existed injoinpath.c and analyzejoins.c. Deduplicate this by moving the functioninto restrictinfo.h.It isn't quite clear that keeping the inline property of this functionis worthwhile, but this commit is just an exercise in codededuplication. More effort would be required to determine if the inlineproperty is worth keeping.Author: James Hunter <james.hunter.pg@gmail.com>Discussion:https://postgr.es/m/CAJVSvF7Nm_9kgMLOch4c-5fbh3MYg%3D9BdnDx3Dv7Fcb64zr64Q%40mail.gmail.com
1 parent7cdfeee commit2453196

File tree

3 files changed

+38
-68
lines changed

3 files changed

+38
-68
lines changed

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

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include"optimizer/paths.h"
2626
#include"optimizer/placeholder.h"
2727
#include"optimizer/planmain.h"
28+
#include"optimizer/restrictinfo.h"
2829
#include"utils/lsyscache.h"
2930
#include"utils/typcache.h"
3031

@@ -58,9 +59,6 @@ static void try_partial_mergejoin_path(PlannerInfo *root,
5859
staticvoidsort_inner_and_outer(PlannerInfo*root,RelOptInfo*joinrel,
5960
RelOptInfo*outerrel,RelOptInfo*innerrel,
6061
JoinTypejointype,JoinPathExtraData*extra);
61-
staticinlineboolclause_sides_match_join(RestrictInfo*rinfo,
62-
RelOptInfo*outerrel,
63-
RelOptInfo*innerrel);
6462
staticvoidmatch_unsorted_outer(PlannerInfo*root,RelOptInfo*joinrel,
6563
RelOptInfo*outerrel,RelOptInfo*innerrel,
6664
JoinTypejointype,JoinPathExtraData*extra);
@@ -470,7 +468,8 @@ paraminfo_get_equal_hashops(PlannerInfo *root, ParamPathInfo *param_info,
470468
* with 2 args.
471469
*/
472470
if (!IsA(opexpr,OpExpr)||list_length(opexpr->args)!=2||
473-
!clause_sides_match_join(rinfo,outerrel,innerrel))
471+
!clause_sides_match_join(rinfo,outerrel->relids,
472+
innerrel->relids))
474473
{
475474
list_free(*operators);
476475
list_free(*param_exprs);
@@ -1320,37 +1319,6 @@ try_partial_hashjoin_path(PlannerInfo *root,
13201319
hashclauses));
13211320
}
13221321

1323-
/*
1324-
* clause_sides_match_join
1325-
* Determine whether a join clause is of the right form to use in this join.
1326-
*
1327-
* We already know that the clause is a binary opclause referencing only the
1328-
* rels in the current join. The point here is to check whether it has the
1329-
* form "outerrel_expr op innerrel_expr" or "innerrel_expr op outerrel_expr",
1330-
* rather than mixing outer and inner vars on either side. If it matches,
1331-
* we set the transient flag outer_is_left to identify which side is which.
1332-
*/
1333-
staticinlinebool
1334-
clause_sides_match_join(RestrictInfo*rinfo,RelOptInfo*outerrel,
1335-
RelOptInfo*innerrel)
1336-
{
1337-
if (bms_is_subset(rinfo->left_relids,outerrel->relids)&&
1338-
bms_is_subset(rinfo->right_relids,innerrel->relids))
1339-
{
1340-
/* lefthand side is outer */
1341-
rinfo->outer_is_left= true;
1342-
return true;
1343-
}
1344-
elseif (bms_is_subset(rinfo->left_relids,innerrel->relids)&&
1345-
bms_is_subset(rinfo->right_relids,outerrel->relids))
1346-
{
1347-
/* righthand side is outer */
1348-
rinfo->outer_is_left= false;
1349-
return true;
1350-
}
1351-
return false;/* no good for these input relations */
1352-
}
1353-
13541322
/*
13551323
* sort_inner_and_outer
13561324
* Create mergejoin join paths by explicitly sorting both the outer and
@@ -2264,7 +2232,8 @@ hash_inner_and_outer(PlannerInfo *root,
22642232
/*
22652233
* Check if clause has the form "outer op inner" or "inner op outer".
22662234
*/
2267-
if (!clause_sides_match_join(restrictinfo,outerrel,innerrel))
2235+
if (!clause_sides_match_join(restrictinfo,outerrel->relids,
2236+
innerrel->relids))
22682237
continue;/* no good for these input relations */
22692238

22702239
/*
@@ -2549,7 +2518,8 @@ select_mergejoin_clauses(PlannerInfo *root,
25492518
/*
25502519
* Check if clause has the form "outer op inner" or "inner op outer".
25512520
*/
2552-
if (!clause_sides_match_join(restrictinfo,outerrel,innerrel))
2521+
if (!clause_sides_match_join(restrictinfo,outerrel->relids,
2522+
innerrel->relids))
25532523
{
25542524
have_nonmergeable_joinclause= true;
25552525
continue;/* no good for these input relations */

‎src/backend/optimizer/plan/analyzejoins.c

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -115,37 +115,6 @@ remove_useless_joins(PlannerInfo *root, List *joinlist)
115115
returnjoinlist;
116116
}
117117

118-
/*
119-
* clause_sides_match_join
120-
* Determine whether a join clause is of the right form to use in this join.
121-
*
122-
* We already know that the clause is a binary opclause referencing only the
123-
* rels in the current join. The point here is to check whether it has the
124-
* form "outerrel_expr op innerrel_expr" or "innerrel_expr op outerrel_expr",
125-
* rather than mixing outer and inner vars on either side. If it matches,
126-
* we set the transient flag outer_is_left to identify which side is which.
127-
*/
128-
staticinlinebool
129-
clause_sides_match_join(RestrictInfo*rinfo,Relidsouterrelids,
130-
Relidsinnerrelids)
131-
{
132-
if (bms_is_subset(rinfo->left_relids,outerrelids)&&
133-
bms_is_subset(rinfo->right_relids,innerrelids))
134-
{
135-
/* lefthand side is outer */
136-
rinfo->outer_is_left= true;
137-
return true;
138-
}
139-
elseif (bms_is_subset(rinfo->left_relids,innerrelids)&&
140-
bms_is_subset(rinfo->right_relids,outerrelids))
141-
{
142-
/* righthand side is outer */
143-
rinfo->outer_is_left= false;
144-
return true;
145-
}
146-
return false;/* no good for these input relations */
147-
}
148-
149118
/*
150119
* join_is_removable
151120
* Check whether we need not perform this special join at all, because

‎src/include/optimizer/restrictinfo.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,35 @@ extern bool join_clause_is_movable_into(RestrictInfo *rinfo,
4848
Relidscurrentrelids,
4949
Relidscurrent_and_outer);
5050

51+
/*
52+
* clause_sides_match_join
53+
* Determine whether a join clause is of the right form to use in this join.
54+
*
55+
* We already know that the clause is a binary opclause referencing only the
56+
* rels in the current join. The point here is to check whether it has the
57+
* form "outerrel_expr op innerrel_expr" or "innerrel_expr op outerrel_expr",
58+
* rather than mixing outer and inner vars on either side. If it matches,
59+
* we set the transient flag outer_is_left to identify which side is which.
60+
*/
61+
staticinlinebool
62+
clause_sides_match_join(RestrictInfo*rinfo,Relidsouterrelids,
63+
Relidsinnerrelids)
64+
{
65+
if (bms_is_subset(rinfo->left_relids,outerrelids)&&
66+
bms_is_subset(rinfo->right_relids,innerrelids))
67+
{
68+
/* lefthand side is outer */
69+
rinfo->outer_is_left= true;
70+
return true;
71+
}
72+
elseif (bms_is_subset(rinfo->left_relids,innerrelids)&&
73+
bms_is_subset(rinfo->right_relids,outerrelids))
74+
{
75+
/* righthand side is outer */
76+
rinfo->outer_is_left= false;
77+
return true;
78+
}
79+
return false;/* no good for these input relations */
80+
}
81+
5182
#endif/* RESTRICTINFO_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp