Proposed patch - psql wraps at window width

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Cc: Bryce Nesbitt <bryce2(at)obviously(dot)com>, heikki(at)enterprisedb(dot)com
Subject: Proposed patch - psql wraps at window width
Date: 2008-04-23 22:30:57
Message-ID: 200804232230.m3NMUvK12983@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

I have moved this discussion to hackers in hopes of getting more
feedback, and moved the patch to a static URL:

ftp://momjian.us/pub/postgresql/mypatches/wrap

This patch adds a new '\pset format wrapped' mode that wraps long values
to fit the table on the user's screen, or in '\pset columns' columns in
an output to file or pipe. The documentation additions are at the top
of the patch.

Sample:

\pset format wrapped
Output format is wrapped.

\pset columns 70
Target column width for "wrap" format is 70.

SELECT 1, 2, repeat('a', 80), repeat('b', 80), E'a\nb\nc', 1
FROM generate_series(1,2)\g

?column? | ?column? | repeat | repeat | ?column? | ?column?
----------+----------+------------+-------------+----------+----------
1 | 2 | aaaaaaaaaa | bbbbbbbbbbb | a | 1
; aaaaaaaaaa ; bbbbbbbbbbb : b
; aaaaaaaaaa ; bbbbbbbbbbb : c
; aaaaaaaaaa ; bbbbbbbbbbb
; aaaaaaaaaa ; bbbbbbbbbbb
; aaaaaaaaaa ; bbbbbbbbbbb
; aaaaaaaaaa ; bbbbbbbbbbb
; aaaaaaaaaa ; bbb
1 | 2 | aaaaaaaaaa | bbbbbbbbbbb | a | 1
; aaaaaaaaaa ; bbbbbbbbbbb : b
; aaaaaaaaaa ; bbbbbbbbbbb : c
; aaaaaaaaaa ; bbbbbbbbbbb
; aaaaaaaaaa ; bbbbbbbbbbb
; aaaaaaaaaa ; bbbbbbbbbbb
; aaaaaaaaaa ; bbbbbbbbbbb
; aaaaaaaaaa ; bbb
(2 rows)

You will notice:

o I have pulled up newline values to appear in the same rows
as the wrapped text
o Colons are used on the left for newline values
o Semicolons are used on the left for wrapped values
o There are no vertical bars for values that don't extend
to the wrapped or newline rows. This is how our
newline display has always worked so it was copied
by the wrapped code
o The left column has no indicator of wrapping or newlines
because there is no left border

We could use dashes to indicated wrapped values, but we don't. It would
be nice if someone could do some multi-byte testing of this,
particularly for characters that have a display width greater than one.

I think this patch is ready for application.

Should 'wrapped' be the default for certain operations, like \df?
'wrapped' mode is really good for a table that would fit the screen
width except for a few wide values.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Brendan Jurd 2008-04-23 22:51:58 Re: Proposed patch - psql wraps at window width
Previous Message Joshua D. Drake 2008-04-23 22:16:18 Re: WIP: psql default banner patch v4

Browse pgsql-patches by date

  From Date Subject
Next Message Brendan Jurd 2008-04-23 22:51:58 Re: Proposed patch - psql wraps at window width
Previous Message Joshua D. Drake 2008-04-23 21:41:20 Patch to change psql default banner