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 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-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 | Content-Type | Size |
---|---|---|
psql_wrapping.patch | text/x-patch | 23.8 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2008-03-05 21:25:29 | Re: NetBSD/MIPS supports dlopen |
Previous Message | Tom Lane | 2008-03-05 20:33:57 | Re: NetBSD/MIPS supports dlopen |
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2008-03-05 21:25:29 | Re: NetBSD/MIPS supports dlopen |
Previous Message | Edwin Groothuis | 2008-03-05 20:49:22 | Re: [BUGS] BUG #3975: tsearch2 index should not bomb out of 1Mb limit |