pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Rajiv Harlalka <rajivharlalka009@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Number of dashes in the expanded view of psql
Date: Sat, 3 Jun 2023 08:05:50 -0700
Message-ID: <bb00e288-15d6-6ca0-2da5-7c685fa51b88@aklaver.com> (raw)
In-Reply-To: <CAO4XbpgEjtNj+dOgWkYpN-Lts4GPzKU3ZLXhU7JzZ6VVW6Ebtg@mail.gmail.com>
References: <CAO4XbpgEjtNj+dOgWkYpN-Lts4GPzKU3ZLXhU7JzZ6VVW6Ebtg@mail.gmail.com>

On 6/3/23 03:12, Rajiv Harlalka wrote:
> Hello,
>       While watching results of some internal tables in pg , looked that 
> the number of dashes between records depends on the char length of the 
> longest column (referring to dashes here -[ RECORD 1 ]-------------).
> Wouldn't it be better to have a better method for number of such dashes 
> as for tables having arrays or similar datatypes, if the length of entry 
> is long enough this can fill up entire TERM_HEIGHT.
> 
>    Regards,
> Rajiv Harlalka,
> 


From

https://www.postgresql.org/docs/current/app-psql.html

\pset

format

  ...

     wrapped format is like aligned but wraps wide data values across 
lines to make the output fit in the target column width. The target 
width is determined as described under the columns option. Note that 
psql will not attempt to wrap column header titles; therefore, wrapped 
format behaves the same as aligned if the total width needed for column 
headers exceeds the target.

...

columns

     Sets the target width for the wrapped format, and also the width 
limit for determining whether output is wide enough to require the pager 
or switch to the vertical display in expanded auto mode. Zero (the 
default) causes the target width to be controlled by the environment 
variable COLUMNS, or the detected screen width if COLUMNS is not set. In 
addition, if columns is zero then the wrapped format only affects screen 
output. If columns is nonzero then file and pipe output is wrapped to 
that width as well.



So:

create table wide_test(id integer, fld_1 varchar, fld_2 varchar);


  insert into wide_test values (1, 
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 
'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'), (2, 
'ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc', 
'dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd');

In below I  am not showing output as is it is distorted by email client. 
You can use the above table and data to see the effect of changing the 
format.

test(5432)=# \pset format aligned
Output format is aligned.

test(5432)=# select * from wide_test ;



test(5432)=# \pset format wrapped
Output format is wrapped.

test(5432)=# select * from wide_test ;



-- 
Adrian Klaver
adrian.klaver@aklaver.com






view thread (2+ messages)

Message-ID: <bb00e288-15d6-6ca0-2da5-7c685fa51b88@aklaver.com>
Permalink:  ../bb00e288-15d6-6ca0-2da5-7c685fa51b88@aklaver.com/
Also on:    postgresql.org/message-id/bb00e288-15d6-6ca0-2da5-7c685fa51b88@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, rajivharlalka009@gmail.com
  Subject: Re: Number of dashes in the expanded view of psql
  In-Reply-To: <bb00e288-15d6-6ca0-2da5-7c685fa51b88@aklaver.com>
  References: <CAO4XbpgEjtNj+dOgWkYpN-Lts4GPzKU3ZLXhU7JzZ6VVW6Ebtg@mail.gmail.com> <bb00e288-15d6-6ca0-2da5-7c685fa51b88@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox