hackity hack elided nodes
authorRobert Haas <rhaas@postgresql.org>
Fri, 30 May 2025 15:28:21 +0000 (11:28 -0400)
committerRobert Haas <rhaas@postgresql.org>
Fri, 30 May 2025 15:28:21 +0000 (11:28 -0400)
contrib/pg_plan_advice/pgpa_join.c
contrib/pg_plan_advice/pgpa_walker.c

index ce32f80d53773fdc60ccff97cda9fc92c5729d44..b3bfef37dca80f16902ffb853e9e164a3bf5ae66 100644 (file)
@@ -67,8 +67,6 @@ pgpa_build_clumped_join(Plan *plan, ElidedNode *elided_node)
 {
        pgpa_clumped_join *clump = palloc(sizeof(pgpa_clumped_join));
 
-       Assert(pgpa_get_join_class(plan) == PGPA_CLUMPED_JOIN);
-
        clump->plan = plan;
 
        if (elided_node != NULL)
@@ -82,7 +80,7 @@ pgpa_build_clumped_join(Plan *plan, ElidedNode *elided_node)
                 * be elided, but in that case we expected only a single RTI, in which
                 * case it's not a join.
                 */
-               Assert(bms_membership(clump->relids) == BMS_MULTIPLE);
+               Assert(bms_membership(elided_node->relids) == BMS_MULTIPLE);
                clump->relids = elided_node->relids;
                if (elided_type == T_Append || elided_type == T_MergeAppend)
                        clump->strategy = JSTRAT_CLUMP_PARTITIONWISE;
@@ -91,6 +89,8 @@ pgpa_build_clumped_join(Plan *plan, ElidedNode *elided_node)
        }
        else
        {
+               Assert(pgpa_get_join_class(plan) == PGPA_CLUMPED_JOIN);
+
                clump->relids = pgpa_relids(plan);
 
                if (IsA(plan, Result))
index 7d8736725c45216aa92bbe5f6c6ff1aac6d185e0..689f151e16290d5f14b350073406bddc5f047bc6 100644 (file)
@@ -18,10 +18,18 @@ pgpa_plan_walker(pgpa_plan_walker_context *context, Plan *plan,
 
        foreach_node(ElidedNode, n, context->pstmt->elidedNodes)
        {
+               pgpa_clumped_join *cjoin;
+
                if (n->plan_node_id != plan->plan_node_id)
                        continue;
 
-               elog(WARNING, "look at me, i'm elided!");
+               join_unroller = NULL;
+
+               if (bms_membership(n->relids) != BMS_MULTIPLE)
+                               continue;
+
+               cjoin = pgpa_build_clumped_join(plan, n);
+               context->clumped_joins = lappend(context->clumped_joins, cjoin);
        }
 
        class = pgpa_get_join_class(plan);
@@ -37,16 +45,15 @@ pgpa_plan_walker(pgpa_plan_walker_context *context, Plan *plan,
                {
                        pgpa_clumped_join *cjoin;
 
-                       cjoin = pgpa_build_clumped_join(plan, NULL); /* XXX FIXME */
+                       cjoin = pgpa_build_clumped_join(plan, NULL);
                        context->clumped_joins = lappend(context->clumped_joins, cjoin);
                }
        }
+
        if (join_unroller != NULL)
                pgpa_unroll_join(context->pstmt, plan, join_unroller,
                                                 &outer_join_unroller, &inner_join_unroller);
 
-       /* XXX I don't know how this is supposed to handle elided nodes. */
-
        if (plan->lefttree != NULL)
                pgpa_plan_walker(context, plan->lefttree, outer_join_unroller);
        if (plan->righttree != NULL)