Re: Proposed patch - psql wraps at window width

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Aidan Van Dyk <aidan(at)highrise(dot)ca>
Cc: Gregory Stark <stark(at)enterprisedb(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Bryce Nesbitt <bryce2(at)obviously(dot)com>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Brendan Jurd <direvus(at)gmail(dot)com>, heikki(at)enterprisedb(dot)com
Subject: Re: Proposed patch - psql wraps at window width
Date: 2008-05-06 15:59:48
Message-ID: 200805061559.m46FxmS08402@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Aidan Van Dyk wrote:
> I have to admit to using the COLUMNS=... <command> trick myself.
>
> I do have COLUMNS exported in my terminal, and often to stuff like:
>
> ls -C | less
>
> and I expect it to wrap at $COLUMNS (my terminal width) in my pager.
>
> And since the GNU coreutils is pretty consistent in this regard, I often
> export COLUMNS=<xxx> in scripts for cron jobs, reports, etc, to get
> output that formats nicely for emails, etc.

Interesting.

> If I ever wanted the psql wrapped format, I guess *I* would hope that
> psql would work that way, simply because that's the way the other tools
> I use do it. But I can see that if the other tools work differently,
> then there is going to have to be some people (maybe everybody) always
> double-checking the psql man page to find out again how it formats.

True.

> But since I'm not a user wanting the wrapped format, don't cater to my
> hypothetical wants.
>
> But one of the interesting things is that psql has an is *interactive*
> mode (something the GNU utils don't have to worry about). So *when* you
> choose to figure out your columns is important, and really impacts
> behaviour too.
>
> For instance, if I was doing a query, I often to it interactively first:
> SELECT [...] FROM [....] LIMIT 50;
> And when I'm sure I have the right values,expressions, column aliases,
> etc, I do:
> \o /tmp/output
> SELECT [...] FROM [...];
> \o
> And in this case, I would expect that /tmp/output would have identical
> formatting to the LIMITed query I just ran interactively, not matter
> what setting I had for format/wrapped/auto/$COLUMNS.

The only thing we could do there perhaps is to have psql wrap file
output to the terminal width if outputting to a pipe/file, but only from
an interactive session, but that is just too odd. If we make psql too
automatic it will be hard to explain and have more surprises.

> `-w'
> `--width=COLS'
> Assume the screen is COLS columns wide. The default is taken from
> the terminal settings if possible; otherwise the environment
> variable `COLUMNS' is used if it is set; otherwise the default is
> 80.

I just looked at coreutils-6.9 and 5.97 and neither manual has a mention
of COLUMNS. Seems this is some Debian manual addition or something. I
don't see it on Ubuntu 7.10 either.

> That's pretty straight forward, pretty explicit, and matches the
> description of what Greg has been saying all along.

Agreed. The problem is I have a pretty even split on how this feature
should behave so we have go to with the majority and adjust as we get
feedback from the field.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2008-05-06 16:00:47 Re: Proposed patch - psql wraps at window width
Previous Message Tom Lane 2008-05-06 15:56:42 Re: [GENERAL] psql \pset pager