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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Rework wrap-width calculation in psql's print_aligned_vertical()
Date: 2015-11-30 22:53:40
Message-ID: E1a3XKG-0002FJ-Pq@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Teodor Sigaev 2015-12-01 15:56:58 pgsql: Use pg_rewind when target timeline was switched
Previous Message Robert Haas 2015-11-30 18:05:45 pgsql: Fix obsolete comment.