Skip site navigation (1) Skip section navigation (2)

Proposed patch - psql wraps at window width

From: Bryce Nesbitt <bryce2(at)obviously(dot)com>
To: pgsql-patches(at)postgresql(dot)org
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, heikki(at)enterprisedb(dot)com
Subject: Proposed patch - psql wraps at window width
Date: 2008-03-05 21:06:12
Message-ID: 47CF0B44.1050504@obviously.com (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
I've attached a patch, against current 8.4 cvs, which optionally sets a 
maximum width for psql output:
 
# \pset format aligned-wrapped
# \pset border 2
# select * from distributors order by did;
+------+--------------------+---------------------+---------------+
| did  |        name        |        descr        | long_col_name |
+------+--------------------+---------------------+---------------+
|    1 | Food fish and wine | default             |               |
|    2 | Cat Food Heaven 2  | abcdefghijklmnopqrs !               |
|      |                    | tuvwxyz             |               |
|    3 | Cat Food Heaven 3  | default             |               |
|   10 | Lah                | default             |               |
|   12 | name               | line one            |               |
| 2892 ! short name         | short               |               |
| 8732 |                    |                     |               |
+------+--------------------+---------------------+---------------+
(8 rows)

The interactive terminal column width comes from
        char * temp = getenv("COLUMNS");
Which has the strong advantage of great simplicity and portability.  But 
it may not be 1000% universal.  If $COLUMNS is not defined, the code 
bails to assuming an infinitely wide terminal.

I will also backport this to Postgres 8.1, for my own use.  Though the 
code is almost totally different in structure.

                         Bryce Nesbitt
                         City CarShare San Francisco


Attachment: psql_wrapping.patch
Description: text/x-patch (23.8 KB)

In response to

Responses

pgsql-hackers by date

Next:From: Alvaro HerreraDate: 2008-03-05 21:25:29
Subject: Re: NetBSD/MIPS supports dlopen
Previous:From: Tom LaneDate: 2008-03-05 20:33:57
Subject: Re: NetBSD/MIPS supports dlopen

pgsql-patches by date

Next:From: Alvaro HerreraDate: 2008-03-05 21:25:29
Subject: Re: NetBSD/MIPS supports dlopen
Previous:From: Edwin GroothuisDate: 2008-03-05 20:49:22
Subject: Re: [BUGS] BUG #3975: tsearch2 index should not bomb out of 1Mb limit

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group