Rework wrap-width calculation in psql's print_aligned_vertical() function.
authorTom Lane
Mon, 30 Nov 2015 22:53:32 +0000 (17:53 -0500)
committerTom Lane
Mon, 30 Nov 2015 22:53:32 +0000 (17:53 -0500)
commit4122ebcb1056655f23193e4632dccce68c524e43
tree0f7ae22d58531a19fd3b1c6b9287beadda9eaab9
parente69d3a82e46461da4c3878487fb99c1294fb1d8f
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.
src/bin/psql/print.c
src/test/regress/expected/psql.out
src/test/regress/sql/psql.sql