Questions about proper newline handling in psql output

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Questions about proper newline handling in psql output
Date: 2005-09-25 20:45:06
Message-ID: 20050925204501.GA11632@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I basically have a functional version for aligned output, examples at
the bottom of this email. It handles multiline data values and
multiline headers. However, there are some areas where I could use some
input.

1. To be able to control the spacing, psql now has to be very careful
about its output. eg \r is printed as \r, ascii control characters are
output as \x00 style and other control chars as \u0000. This is a
change from previous behaviour, yet you're pretty much forced to if you
want to control the output.

Is this change acceptable?

2. Currently I've changed the aligned outputs but not the unaligned
ones. Given you're not worrying about alignment there anyway, why do
the work? Also, we recommend unaligned output for script users so I
don't feel right changing it.

Is this distinction acceptable?

3. How to show that a value is continued? As you can see below I use
':' before columns that have data. This obviously doesn't work for
first column if there's no outer border. If your border style is 0
you're totally out of luck.

I remember a discussion on this before but couldn't find it in the
archives. Either a reference or some other hints would be appreciated.

4. Some system output like pg_views has really really long strings,
would it be acceptable to change the output there to add newlines at
various places to make it output nicer with this change?

5. Auto string folding. If a string is really long, fold it so it fits
in a screen width, perhaps with '\' continuation. I havn't done this
but I can imagine some people (including me) would love it.

6. Currently I've implemented support for UTF-8 and all ASCII
compatable single-byte encodings. Given that psql didn't support the
others anyway maybe no-one cares, but I have to ask: does anyone care?
If so, I need info on *how* to support an encoding.

Thanks for your attention. See you tomorrow.

Query is: select oid, prosrc as "HdrLine1
HdrLine2", proacl from pg_proc limit 1;

Border style is 1.
oid | HdrLine1 | proacl
| HdrLine2 |
-------+---------------------------------------------------------------------+--------
17009 | select 1 union all select 2 union all select 3 union all |
: select 4 union all select 5 union all select 6 union all
: select 7 union all select 8 union all select 9 union all
: select 10 union all select 11 union all select 12 union all
: select 13 union all select 14 union all select 15 union all
: select 16 union all select 17 union all select 18 union all
: select 19 union all select 20 union all select 21 union all
: select 22 union all select 23 union all select 24 union all
: select 25 union all select 26 union all select 27 union all
: select 28 union all select 29 union all select 30 union all
: select 31 union all select 32
(1 row)

Expanded display is on.
-[ RECORD 1 ]-----------------------------------------------------------------
oid | 17009
HdrLine1 | select 1 union all select 2 union all select 3 union all
HdrLine2 : select 4 union all select 5 union all select 6 union all
: select 7 union all select 8 union all select 9 union all
: select 10 union all select 11 union all select 12 union all
: select 13 union all select 14 union all select 15 union all
: select 16 union all select 17 union all select 18 union all
: select 19 union all select 20 union all select 21 union all
: select 22 union all select 23 union all select 24 union all
: select 25 union all select 26 union all select 27 union all
: select 28 union all select 29 union all select 30 union all
: select 31 union all select 32
proacl |

# select chr(8);
chr
------
\x08
(1 row)

--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Oliver Jowett 2005-09-25 23:27:23 Re: statement logging / extended query protocol issues
Previous Message Simon Riggs 2005-09-25 18:31:36 Re: [HACKERS] statement logging / extended query protocol issues