move more code to pgpa_output.c
authorRobert Haas <rhaas@postgresql.org>
Thu, 26 Jun 2025 17:59:40 +0000 (13:59 -0400)
committerRobert Haas <rhaas@postgresql.org>
Thu, 26 Jun 2025 17:59:40 +0000 (13:59 -0400)
contrib/pg_plan_advice/pg_plan_advice.c
contrib/pg_plan_advice/pgpa_output.c

index 6a90dfc89e2e926f006d3a9661980a0f48848baa..6925ac4963b46c0c1fef58a1ac86d892597b56fd 100644 (file)
@@ -70,27 +70,6 @@ pgpa_check_plan(PlannedStmt *pstmt)
        }
 
        initStringInfo(&buf);
-       foreach(lc, context.unrolled_joins)
-       {
-               pgpa_unrolled_join *ujoin = lfirst(lc);
-
-               appendStringInfoChar(&buf, ' ');
-               pgpa_debug_out_unrolled_join(&buf, ujoin, rt_identifiers);
-       }
-       foreach(lc, context.clumped_joins)
-       {
-               pgpa_clumped_join *cjoin = lfirst(lc);
-
-               appendStringInfoChar(&buf, ' ');
-               pgpa_debug_out_clumped_join(&buf, cjoin, rt_identifiers);
-       }
-       foreach(lc, context.gathered_joins)
-       {
-               pgpa_gathered_join *gathered_join = lfirst(lc);
-
-               appendStringInfoChar(&buf, ' ');
-               pgpa_debug_out_gathered_join(&buf, gathered_join, rt_identifiers);
-       }
-
+       pgpa_output_advice(&buf, &context, rt_identifiers);
        elog(LOG, "advice:%s", buf.data);
 }
index 907212cebbe577617ef6d869b384d1bb4d4ccd59..9c04405b5571f73956b4f8b75f8352ea6a7ae6fc 100644 (file)
@@ -20,6 +20,37 @@ static void pgpa_debug_out_join_member(StringInfo buf,
 static char *pgpa_cstring_join_clump_strategy(pgpa_join_clump_strategy strategy);
 static char *pgpa_cstring_join_strategy(pgpa_join_strategy strategy);
 
+void
+pgpa_output_advice(StringInfo buf, pgpa_plan_walker_context *context,
+                                  const char **rt_identifiers)
+{
+       ListCell   *lc;
+
+       foreach(lc, context->unrolled_joins)
+       {
+               pgpa_unrolled_join *ujoin = lfirst(lc);
+
+               appendStringInfoChar(buf, ' ');
+               pgpa_debug_out_unrolled_join(buf, ujoin, rt_identifiers);
+       }
+
+       foreach(lc, context->clumped_joins)
+       {
+               pgpa_clumped_join *cjoin = lfirst(lc);
+
+               appendStringInfoChar(buf, ' ');
+               pgpa_debug_out_clumped_join(buf, cjoin, rt_identifiers);
+       }
+
+       foreach(lc, context->gathered_joins)
+       {
+               pgpa_gathered_join *gathered_join = lfirst(lc);
+
+               appendStringInfoChar(buf, ' ');
+               pgpa_debug_out_gathered_join(buf, gathered_join, rt_identifiers);
+       }
+}
+
 void
 pgpa_debug_out_clumped_join(StringInfo buf, pgpa_clumped_join *clump,
                                                        const char **rt_identifiers)