Ok, So I've hacked on this a bit. Below is a test case showing the
problems I've found.
1) It isn't using the "newline" and "wrap" indicators or dividing lines.
2) The header is not being displayed properly when it contains a newline.
I can hack in the newline and wrap indicators but the header
formatting requires reworking the logic a bit. The header and data
need to be stepped through in parallel rather than having a loop to
handle the wrapping within the handling of a single line. I don't
really have time for that today but if you can get to it that would be
fine,
postgres=***# \pset
Border style (border) is 2.
Target width (columns) is 20.
Expanded display (expanded) is on.
Field separator (fieldsep) is "|".
Default footer (footer) is on.
Output format (format) is wrapped.
Line style (linestyle) is unicode.
Null display (null) is "".
Locale-adjusted numeric output (numericlocale) is off.
Pager (pager) usage is off.
Record separator (recordsep) is <newline>.
Table attributes (tableattr) unset.
Title (title) unset.
Tuples only (tuples_only) is off.
postgres=***# select array_to_string(array_agg(repeat('x',n)),E'\n') as "x
y", array_to_string(array_agg(repeat('yy',10-n)),E'\n') as "x
y
z" from (select generate_series(1,10)) as t(n);
┌─[ RECORD 1 ]─────┐
│ x │ x │
│ y │ xx │
│ │ xxx │
│ │ xxxx │
│ │ xxxxx │
│ │ xxxxxx │
│ │ xxxxxxx │
│ │ xxxxxxxx │
│ │ xxxxxxxxx │
│ │ xxxxxxxxxx │
│ x │ yyyyyyyyyyyy │
│ │ yyyyyy │
│ y │ yyyyyyyyyyyy │
│ │ yyyy │
│ z │ yyyyyyyyyyyy │
│ │ yy │
│ │ yyyyyyyyyyyy │
│ │ yyyyyyyyyy │
│ │ yyyyyyyy │
│ │ yyyyyy │
│ │ yyyy │
│ │ yy │
│ │ │
└───┴──────────────┘
postgres=***# \pset linestyle ascii
Line style (linestyle) is ascii.
postgres=***# select array_to_string(array_agg(repeat('x',n)),E'\n') as "x
y", array_to_string(array_agg(repeat('yy',10-n)),E'\n') as "x
y
z" from (select generate_series(1,10)) as t(n);
+-[ RECORD 1 ]-----+
| x | x |
| y | xx |
| | xxx |
| | xxxx |
| | xxxxx |
| | xxxxxx |
| | xxxxxxx |
| | xxxxxxxx |
| | xxxxxxxxx |
| | xxxxxxxxxx |
| x | yyyyyyyyyyyy |
| | yyyyyy |
| y | yyyyyyyyyyyy |
| | yyyy |
| z | yyyyyyyyyyyy |
| | yy |
| | yyyyyyyyyyyy |
| | yyyyyyyyyy |
| | yyyyyyyy |
| | yyyyyy |
| | yyyy |
| | yy |
| | |
+---+--------------+
postgres=***# \pset columns 30
Target width (columns) is 30.
postgres=***# \pset linestyle unicode
Line style (linestyle) is unicode.
postgres=***# \pset columns 30
Target width (columns) is 30.
postgres=***# \pset expanded off
Expanded display (expanded) is off.
postgres=***# select array_to_string(array_agg(repeat('x',n)),E'\n') as "x
y", array_to_string(array_agg(repeat('yy',10-n)),E'\n') as "x
y
z" from (select generate_series(1,10)) as t(n);
┌───────────┬────────────────┐
│ x ↵│ x ↵│
│ y │ y ↵│
│ │ z │
├───────────┼────────────────┤
│ x ↵│ yyyyyyyyyyyyyy…│
│ xx ↵│…yyyy ↵│
│ xxx ↵│ yyyyyyyyyyyyyy…│
│ xxxx ↵│…yy ↵│
│ xxxxx ↵│ yyyyyyyyyyyyyy↵│
│ xxxxxx ↵│ yyyyyyyyyyyy ↵│
│ xxxxxxx ↵│ yyyyyyyyyy ↵│
│ xxxxxxxx ↵│ yyyyyyyy ↵│
│ xxxxxxxxx↵│ yyyyyy ↵│
│ xxxxxxxxx…│ yyyy ↵│
│…x │ yy ↵│
│ │ │
└───────────┴────────────────┘
(1 row)
postgres=***# \pset linestyle ascii
Line style (linestyle) is ascii.
postgres=***# select array_to_string(array_agg(repeat('x',n)),E'\n') as "x
y", array_to_string(array_agg(repeat('yy',10-n)),E'\n') as "x
y
z" from (select generate_series(1,10)) as t(n);
+-----------+----------------+
| x +| x +|
| y | y +|
| | z |
+-----------+----------------+
| x +| yyyyyyyyyyyyyy.|
| xx +|.yyyy +|
| xxx +| yyyyyyyyyyyyyy.|
| xxxx +|.yy +|
| xxxxx +| yyyyyyyyyyyyyy+|
| xxxxxx +| yyyyyyyyyyyy +|
| xxxxxxx +| yyyyyyyyyy +|
| xxxxxxxx +| yyyyyyyy +|
| xxxxxxxxx+| yyyyyy +|
| xxxxxxxxx.| yyyy +|
|.x | yy +|
| | |
+-----------+----------------+
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers