Move wrap_column into pgpa_output_context
authorRobert Haas <rhaas@postgresql.org>
Fri, 27 Jun 2025 14:39:40 +0000 (10:39 -0400)
committerRobert Haas <rhaas@postgresql.org>
Fri, 27 Jun 2025 14:39:40 +0000 (10:39 -0400)
contrib/pg_plan_advice/pgpa_output.c

index 2c101090a6b5693ea82452e49f59e4ae2b6b7345..8491ce6c6eeeaa9d8fc6ddfa071245708c95b2a1 100644 (file)
@@ -18,6 +18,7 @@ typedef struct pgpa_output_context
 {
        const char **rt_identifiers;
        StringInfo      buf;
+       int                     wrap_column;
 } pgpa_output_context;
 
 static void pgpa_debug_out_clumped_join(pgpa_output_context *context,
@@ -44,6 +45,7 @@ pgpa_output_advice(StringInfo buf, pgpa_plan_walker_context *walker,
 
        context.rt_identifiers = rt_identifiers;
        context.buf = buf;
+       context.wrap_column = 79;       /* XXX */
 
        foreach(lc, walker->unrolled_joins)
        {
@@ -97,7 +99,7 @@ pgpa_debug_out_clumped_join(pgpa_output_context *context,
                }
                else
                {
-                       pgpa_maybe_linebreak(context->buf, 79);
+                       pgpa_maybe_linebreak(context->buf, context->wrap_column);
                        appendStringInfo(context->buf, " %s", identifier);
                }
        }
@@ -119,11 +121,11 @@ pgpa_debug_out_unrolled_join(pgpa_output_context *context,
        {
                char       *cstrategy;
 
-               pgpa_maybe_linebreak(context->buf, 79);
+               pgpa_maybe_linebreak(context->buf, context->wrap_column);
                cstrategy = pgpa_cstring_join_strategy(join->strategy[k]);
                appendStringInfo(context->buf, " %s", cstrategy);
 
-               pgpa_maybe_linebreak(context->buf, 79);
+               pgpa_maybe_linebreak(context->buf, context->wrap_column);
                appendStringInfoChar(context->buf, ' ');
                pgpa_debug_out_join_member(context, &join->inner[k]);
        }
@@ -160,7 +162,7 @@ pgpa_debug_out_gathered_join(pgpa_output_context *context,
                }
                else
                {
-                       pgpa_maybe_linebreak(context->buf, 79);
+                       pgpa_maybe_linebreak(context->buf, context->wrap_column);
                        appendStringInfo(context->buf, " %s", identifier);
                }
        }