|
25 | 25 | #include "optimizer/paths.h"
|
26 | 26 | #include "optimizer/placeholder.h"
|
27 | 27 | #include "optimizer/planmain.h"
|
| 28 | +#include "optimizer/restrictinfo.h" |
28 | 29 | #include "utils/lsyscache.h"
|
29 | 30 | #include "utils/typcache.h"
|
30 | 31 |
|
@@ -58,9 +59,6 @@ static void try_partial_mergejoin_path(PlannerInfo *root,
|
58 | 59 | static void sort_inner_and_outer(PlannerInfo *root, RelOptInfo *joinrel,
|
59 | 60 | RelOptInfo *outerrel, RelOptInfo *innerrel,
|
60 | 61 | JoinType jointype, JoinPathExtraData *extra);
|
61 |
| -static inline bool clause_sides_match_join(RestrictInfo *rinfo, |
62 |
| - RelOptInfo *outerrel, |
63 |
| - RelOptInfo *innerrel); |
64 | 62 | static void match_unsorted_outer(PlannerInfo *root, RelOptInfo *joinrel,
|
65 | 63 | RelOptInfo *outerrel, RelOptInfo *innerrel,
|
66 | 64 | JoinType jointype, JoinPathExtraData *extra);
|
@@ -470,7 +468,8 @@ paraminfo_get_equal_hashops(PlannerInfo *root, ParamPathInfo *param_info,
|
470 | 468 | * with 2 args.
|
471 | 469 | */
|
472 | 470 | 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)) |
474 | 473 | {
|
475 | 474 | list_free(*operators);
|
476 | 475 | list_free(*param_exprs);
|
@@ -1320,37 +1319,6 @@ try_partial_hashjoin_path(PlannerInfo *root,
|
1320 | 1319 | hashclauses));
|
1321 | 1320 | }
|
1322 | 1321 |
|
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 |
| -static inline bool |
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 |
| - else if (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 |
| - |
1354 | 1322 | /*
|
1355 | 1323 | * sort_inner_and_outer
|
1356 | 1324 | * Create mergejoin join paths by explicitly sorting both the outer and
|
@@ -2264,7 +2232,8 @@ hash_inner_and_outer(PlannerInfo *root,
|
2264 | 2232 | /*
|
2265 | 2233 | * Check if clause has the form "outer op inner" or "inner op outer".
|
2266 | 2234 | */
|
2267 |
| - if (!clause_sides_match_join(restrictinfo, outerrel, innerrel)) |
| 2235 | + if (!clause_sides_match_join(restrictinfo, outerrel->relids, |
| 2236 | + innerrel->relids)) |
2268 | 2237 | continue; /* no good for these input relations */
|
2269 | 2238 |
|
2270 | 2239 | /*
|
@@ -2549,7 +2518,8 @@ select_mergejoin_clauses(PlannerInfo *root,
|
2549 | 2518 | /*
|
2550 | 2519 | * Check if clause has the form "outer op inner" or "inner op outer".
|
2551 | 2520 | */
|
2552 |
| - if (!clause_sides_match_join(restrictinfo, outerrel, innerrel)) |
| 2521 | + if (!clause_sides_match_join(restrictinfo, outerrel->relids, |
| 2522 | + innerrel->relids)) |
2553 | 2523 | {
|
2554 | 2524 | have_nonmergeable_joinclause = true;
|
2555 | 2525 | continue; /* no good for these input relations */
|
|
0 commit comments