From: Robert Haas Date: Fri, 30 May 2025 15:28:21 +0000 (-0400) Subject: hackity hack elided nodes X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=2f1ad8b6e627a003c7eba22f70f9177f5e37c0d4;p=users%2Frhaas%2Fpostgres.git hackity hack elided nodes --- diff --git a/contrib/pg_plan_advice/pgpa_join.c b/contrib/pg_plan_advice/pgpa_join.c index ce32f80d53..b3bfef37dc 100644 --- a/contrib/pg_plan_advice/pgpa_join.c +++ b/contrib/pg_plan_advice/pgpa_join.c @@ -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)) diff --git a/contrib/pg_plan_advice/pgpa_walker.c b/contrib/pg_plan_advice/pgpa_walker.c index 7d8736725c..689f151e16 100644 --- a/contrib/pg_plan_advice/pgpa_walker.c +++ b/contrib/pg_plan_advice/pgpa_walker.c @@ -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)