OSDN Git Service

New tool to generate source files for copied functions
[pghintplan/pg_hint_plan.git] / make_join_rel.c
index ac8e0c2..9bc9e1c 100644 (file)
@@ -7,20 +7,16 @@
  * src/backend/optimizer/path/joinrels.c
  *     make_join_rel()
  *
- * Portions Copyright (c) 2013-2017, NIPPON TELEGRAPH AND TELEPHONE CORPORATION
- * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
+ * Portions Copyright (c) 2013-2020, NIPPON TELEGRAPH AND TELEPHONE CORPORATION
+ * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  *-------------------------------------------------------------------------
  */
 
-static void populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1,
-                                                                               RelOptInfo *rel2, RelOptInfo *joinrel,
-                                                                               SpecialJoinInfo *sjinfo,
-                                                                               List *restrictlist);
 /*
  * adjust_rows: tweak estimated row numbers according to the hint.
-*/
+ */
 static double
 adjust_rows(double rows, RowsHint *hint)
 {
@@ -160,7 +156,7 @@ make_join_rel(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2)
                                /*
                                 * If the rows_hint's target relids is not a subset of both of
                                 * component rels and is a subset of this joinrel, ths hint's
-                                * targets spread over both component rels. This menas that
+                                * targets spread over both component rels. This means that
                                 * this hint has been never applied so far and this joinrel is
                                 * the first (and only) chance to fire in current join tree.
                                 * Only the multiplication hint has the cumulative nature so we
@@ -174,7 +170,7 @@ make_join_rel(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2)
                {
                        /*
                         * If a hint just for me is found, no other adjust method is
-                        * useles, but this cannot be more than twice becuase this joinrel
+                        * useless, but this cannot be more than twice becuase this joinrel
                         * is already adjusted by this hint.
                         */
                        if (justforme->base.state == HINT_STATE_NOTUSED)
@@ -255,7 +251,7 @@ populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1,
        {
                case JOIN_INNER:
                        if (is_dummy_rel(rel1) || is_dummy_rel(rel2) ||
-                               restriction_is_constant_false(restrictlist, false))
+                               restriction_is_constant_false(restrictlist, joinrel, false))
                        {
                                mark_dummy_rel(joinrel);
                                break;
@@ -269,12 +265,12 @@ populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1,
                        break;
                case JOIN_LEFT:
                        if (is_dummy_rel(rel1) ||
-                               restriction_is_constant_false(restrictlist, true))
+                               restriction_is_constant_false(restrictlist, joinrel, true))
                        {
                                mark_dummy_rel(joinrel);
                                break;
                        }
-                       if (restriction_is_constant_false(restrictlist, false) &&
+                       if (restriction_is_constant_false(restrictlist, joinrel, false) &&
                                bms_is_subset(rel2->relids, sjinfo->syn_righthand))
                                mark_dummy_rel(rel2);
                        add_paths_to_joinrel(root, joinrel, rel1, rel2,
@@ -286,7 +282,7 @@ populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1,
                        break;
                case JOIN_FULL:
                        if ((is_dummy_rel(rel1) && is_dummy_rel(rel2)) ||
-                               restriction_is_constant_false(restrictlist, true))
+                               restriction_is_constant_false(restrictlist, joinrel, true))
                        {
                                mark_dummy_rel(joinrel);
                                break;
@@ -322,7 +318,7 @@ populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1,
                                bms_is_subset(sjinfo->min_righthand, rel2->relids))
                        {
                                if (is_dummy_rel(rel1) || is_dummy_rel(rel2) ||
-                                       restriction_is_constant_false(restrictlist, false))
+                                       restriction_is_constant_false(restrictlist, joinrel, false))
                                {
                                        mark_dummy_rel(joinrel);
                                        break;
@@ -345,7 +341,7 @@ populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1,
                                                                   sjinfo) != NULL)
                        {
                                if (is_dummy_rel(rel1) || is_dummy_rel(rel2) ||
-                                       restriction_is_constant_false(restrictlist, false))
+                                       restriction_is_constant_false(restrictlist, joinrel, false))
                                {
                                        mark_dummy_rel(joinrel);
                                        break;
@@ -360,12 +356,12 @@ populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1,
                        break;
                case JOIN_ANTI:
                        if (is_dummy_rel(rel1) ||
-                               restriction_is_constant_false(restrictlist, true))
+                               restriction_is_constant_false(restrictlist, joinrel, true))
                        {
                                mark_dummy_rel(joinrel);
                                break;
                        }
-                       if (restriction_is_constant_false(restrictlist, false) &&
+                       if (restriction_is_constant_false(restrictlist, joinrel, false) &&
                                bms_is_subset(rel2->relids, sjinfo->syn_righthand))
                                mark_dummy_rel(rel2);
                        add_paths_to_joinrel(root, joinrel, rel1, rel2,
@@ -377,4 +373,7 @@ populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1,
                        elog(ERROR, "unrecognized join type: %d", (int) sjinfo->jointype);
                        break;
        }
+
+       /* Apply partitionwise join technique, if possible. */
+       try_partitionwise_join(root, rel1, rel2, joinrel, sjinfo, restrictlist);
 }