ListCell *lc;
pgpa_output_context context;
+ /*
+ * If the user chooses to use EXPLAIN (PLAN_ADVICE) in an 80-column window
+ * from a psql client with default settings, psql will add one space to the
+ * left of the output and EXPLAIN will add two more to the left of the
+ * advice. Thus, lines of more than 77 characters will wrap. We set the
+ * wrap limit to 76 here so that the output won't reach all the way to the
+ * very last column of the terminal.
+ *
+ * Of course, this is fairly arbitrary set of assumptions, and one could
+ * well make an argument for a different wrap limit, or for a configurable
+ * one.
+ */
memset(&context, 0, sizeof(pgpa_output_context));
context.rt_identifiers = rt_identifiers;
context.buf = buf;
- context.wrap_column = 79; /* XXX */
+ context.wrap_column = 76;
/*
* Put all the top-level scans for each strategy into a single list.
appendStringInfo(context.buf, "JOIN_ORDER(");
pgpa_output_unrolled_join(&context, ujoin);
appendStringInfoChar(context.buf, ')');
+ pgpa_maybe_linebreak(context.buf, context.wrap_column);
}
/*
}
}
appendStringInfoChar(buf, ')');
+ pgpa_maybe_linebreak(context.buf, context.wrap_column);
}
/*
}
}
appendStringInfoChar(buf, ')');
+ pgpa_maybe_linebreak(context.buf, context.wrap_column);
}
/* Sort query features into one list per query feature type. */
}
}
appendStringInfoChar(buf, ')');
+ pgpa_maybe_linebreak(context.buf, context.wrap_column);
}
}
enlargeStringInfo(buf, 1);
memmove(&buf->data[save_cursor] + 1, &buf->data[save_cursor],
buf->len - save_cursor);
- buf->len++;
+ ++buf->cursor;
+ buf->data[++buf->len] = '\0';
buf->data[save_cursor] = '\n';
}