From: Robert Haas Date: Fri, 11 Mar 2016 13:04:01 +0000 (-0500) Subject: psql: Don't automatically use expanded format when there's 1 column. X-Git-Tag: REL9_6_BETA1~520 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=69ab7b9d6c9b9e1d782ffad6e440a3615c63f621;p=thirdparty%2Fpostgresql.git psql: Don't automatically use expanded format when there's 1 column. Andreas Karlsson and Robert Haas --- diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index f2ea63bb6c4..8a8580411ee 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -2119,8 +2119,9 @@ lo_import 152801 column name on the left and the data on the right. This mode is useful if the data wouldn't fit on the screen in the normal horizontal mode. In the auto setting, the - expanded mode is used whenever the query output is wider than the - screen, otherwise the regular mode is used. The auto setting is only + expanded mode is used whenever the query output has more than one + column and is wider than the screen; otherwise, the regular mode is + used. The auto setting is only effective in the aligned and wrapped formats. In other formats, it always behaves as if the expanded mode is off. diff --git a/src/bin/psql/print.c b/src/bin/psql/print.c index 8958903e140..85dbd300d8d 100644 --- a/src/bin/psql/print.c +++ b/src/bin/psql/print.c @@ -816,9 +816,11 @@ print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager) /* * If in expanded auto mode, we have now calculated the expected width, so - * we can now escape to vertical mode if necessary. + * we can now escape to vertical mode if necessary. If the output has + * only one column, the expanded format would be wider than the regular + * format, so don't use it in that case. */ - if (cont->opt->expanded == 2 && output_columns > 0 && + if (cont->opt->expanded == 2 && output_columns > 0 && cont->ncolumns > 1 && (output_columns < total_header_width || output_columns < width_total)) { print_aligned_vertical(cont, fout, is_pager);