Re: psql format output - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: psql format output
Date
Msg-id 202112201536.qrw7pnwwjnya@alvherre.pgsql
Whole thread Raw
In response to Re: psql format output  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On 2021-Dec-20, Tom Lane wrote:

> -[ RECORD 1
]-------+-----------------------------------------------------------------------------------------------------------
> Schema              | pg_catalog
> Name                | pg_copy_logical_replication_slot
> Result data type    | record
> Argument data types | src_slot_name name, dst_slot_name name, OUT slot_name name, OUT lsn pg_lsn

> The OP wants to fix that by inserting newlines in the "Argument data
> types" column, which'd help, but it seems to me to be mostly a kluge.
> That's prejudging a lot about how the output will be displayed.
> A more SQL-ish way to do things would be to turn the argument items
> into a set of rows.  I don't quite see how to make that work here,
> but maybe I'm just undercaffeinated as yet.

Maybe one way to improve on this is to have the server inject optional
line break markers (perhaps U+FEFF) that the client chooses whether or
not to convert into a physical line break, based on line length.  So in
\df we would use a query that emits such a marker after every comma and
then psql measures line width and crams as many items in each line as
will fit.  In the above example you would still have a single line for
arguments, because your terminal seems wide enough, but if you use a
smaller terminal then it'd be broken across several.

psql controls what happens because it owns the \df query anyway.  It
could be something simple like

pg_catalog.add_psql_linebreaks(pg_catalog.pg_get_function_arguments(p.oid))

if we don't want to intrude into pg_get_function_arguments itself.

-- 
Álvaro Herrera         PostgreSQL Developer  —  https://www.EnterpriseDB.com/
"Always assume the user will do much worse than the stupidest thing
you can imagine."                                (Julien PUYDT)



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: psql format output
Next
From: Pavel Borisov
Date:
Subject: Re: [PATCH] Improve amcheck to also check UNIQUE constraint in btree index.