Skip to content

Commit 69ab7b9

Browse files
committed
psql: Don't automatically use expanded format when there's 1 column.
Andreas Karlsson and Robert Haas
1 parent 481c76a commit 69ab7b9

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

doc/src/sgml/ref/psql-ref.sgml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2119,8 +2119,9 @@ lo_import 152801
21192119
column name on the left and the data on the right. This mode is
21202120
useful if the data wouldn't fit on the screen in the
21212121
normal <quote>horizontal</quote> mode. In the auto setting, the
2122-
expanded mode is used whenever the query output is wider than the
2123-
screen, otherwise the regular mode is used. The auto setting is only
2122+
expanded mode is used whenever the query output has more than one
2123+
column and is wider than the screen; otherwise, the regular mode is
2124+
used. The auto setting is only
21242125
effective in the aligned and wrapped formats. In other formats, it
21252126
always behaves as if the expanded mode is off.
21262127
</para>

src/bin/psql/print.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -816,9 +816,11 @@ print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
816816

817817
/*
818818
* If in expanded auto mode, we have now calculated the expected width, so
819-
* we can now escape to vertical mode if necessary.
819+
* we can now escape to vertical mode if necessary. If the output has
820+
* only one column, the expanded format would be wider than the regular
821+
* format, so don't use it in that case.
820822
*/
821-
if (cont->opt->expanded == 2 && output_columns > 0 &&
823+
if (cont->opt->expanded == 2 && output_columns > 0 && cont->ncolumns > 1 &&
822824
(output_columns < total_header_width || output_columns < width_total))
823825
{
824826
print_aligned_vertical(cont, fout, is_pager);

0 commit comments

Comments
 (0)