Proposed patch - psql wraps at window width - Mailing list pgsql-hackers

From Bruce Momjian
Subject Proposed patch - psql wraps at window width
Date
Msg-id 200804232230.m3NMUvK12983@momjian.us
Whole thread Raw
Responses Re: Proposed patch - psql wraps at window width  ("Brendan Jurd" <direvus@gmail.com>)
List pgsql-hackers
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 wrappedOutput format is wrapped.
\pset columns 70Target column width for "wrap" format is 70.
SELECT 1, 2, repeat('a', 80), repeat('b', 80), E'a\nb\nc', 1FROM 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 texto  Colons are used on the left for
newlinevalueso  Semicolons are used on the left for wrapped valueso  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
wrappedcodeo  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@momjian.us>        http://momjian.us EnterpriseDB
http://enterprisedb.com
 + If your life is a hard drive, Christ can be your backup. +


pgsql-hackers by date:

Previous
From: "Joshua D. Drake"
Date:
Subject: Re: WIP: psql default banner patch v4
Next
From: "Brendan Jurd"
Date:
Subject: Re: Proposed patch - psql wraps at window width