Thread: pgsql: Rework wrap-width calculation in psql's print_aligned_vertical()

pgsql: Rework wrap-width calculation in psql's print_aligned_vertical()

From
Tom Lane
Date:
Rework wrap-width calculation in psql's print_aligned_vertical() function.

This area was rather heavily whacked around in 6513633b9 and follow-on
commits, and it was showing it, because the logic to calculate the
allowable data width in wrapped expanded mode had only the vaguest
relationship to the logic that was actually printing the data.  It was
not very close to being right about the conditions requiring overhead
columns to be added.  Aside from being wrong, it was pretty unreadable
and under-commented.  Rewrite it so it corresponds to what the printing
code actually does.

In passing, remove a couple of dead tests in the printing logic, too.

Per a complaint from Jeff Janes, though this doesn't look much like his
patch because it fixes a number of other corner-case bogosities too.
One such fix that's visible in the regression test results is that
although the code was attempting to enforce a minimum data width of
3 columns, it sometimes left less space than that available.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/0e0776bc99553ff229e0d536ed8c78ab9db62464

Modified Files
--------------
src/bin/psql/print.c               |  127 +++++----
src/test/regress/expected/psql.out |  509 ++++++++++++++++++++++++++++--------
src/test/regress/sql/psql.sql      |   27 ++
3 files changed, 510 insertions(+), 153 deletions(-)