split up psql \d Modifiers column

Started by Peter Eisentrautover 9 years ago4 messageshackers
Jump to latest
#1Peter Eisentraut
peter_e@gmx.net

I propose to change the psql \d output a bit, best shown with an example:

 \d persons3
-       Table "public.persons3"
- Column |  Type   |    Modifiers
---------+---------+------------------
- id     | integer | not null
- name   | text    | default ''::text
+              Table "public.persons3"
+ Column |  Type   | Collation | Nullable | Default
+--------+---------+-----------+----------+----------
+ id     | integer |           | not null |
+ name   | text    |           |          | ''::text

The "Modifiers" column used to be "the rest", but now \d+ adds
additional columns, so throwing these three things into one column makes
less sense.

Also, some parts of that column are currently marked as translatable,
but it is not clear whether this is supposed to be an English
description or SQL text. By reducing the column contents to just the
data and moving the description to the column header, this weirdness is
avoided.

If you're worried about horizontal space, note that if a column has all
three properties, this will actually save space because the words
"collate" and "default" go away.

Patch attached. Most of it is test output changes; the code changes are
in src/bin/psql/describe.c.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachments:

0001-psql-Split-up-Modifiers-column-in-d.patchtext/x-patch; name=0001-psql-Split-up-Modifiers-column-in-d.patchDownload+1130-963
#2Pavel Stehule
pavel.stehule@gmail.com
In reply to: Peter Eisentraut (#1)
Re: split up psql \d Modifiers column

2016-10-28 5:30 GMT+02:00 Peter Eisentraut <peter.eisentraut@2ndquadrant.com

:

I propose to change the psql \d output a bit, best shown with an example:

\d persons3
-       Table "public.persons3"
- Column |  Type   |    Modifiers
---------+---------+------------------
- id     | integer | not null
- name   | text    | default ''::text
+              Table "public.persons3"
+ Column |  Type   | Collation | Nullable | Default
+--------+---------+-----------+----------+----------
+ id     | integer |           | not null |
+ name   | text    |           |          | ''::text

The "Modifiers" column used to be "the rest", but now \d+ adds
additional columns, so throwing these three things into one column makes
less sense.

Also, some parts of that column are currently marked as translatable,
but it is not clear whether this is supposed to be an English
description or SQL text. By reducing the column contents to just the
data and moving the description to the column header, this weirdness is
avoided.

If you're worried about horizontal space, note that if a column has all
three properties, this will actually save space because the words
"collate" and "default" go away.

Patch attached. Most of it is test output changes; the code changes are
in src/bin/psql/describe.c.

has sense

+ 1

Pavel

Show quoted text

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Kuntal Ghosh
kuntalghosh.2007@gmail.com
In reply to: Peter Eisentraut (#1)
Re: split up psql \d Modifiers column

On Fri, Oct 28, 2016 at 9:00 AM, Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> wrote:

I propose to change the psql \d output a bit, best shown with an example:

\d persons3
-       Table "public.persons3"
- Column |  Type   |    Modifiers
---------+---------+------------------
- id     | integer | not null
- name   | text    | default ''::text
+              Table "public.persons3"
+ Column |  Type   | Collation | Nullable | Default
+--------+---------+-----------+----------+----------
+ id     | integer |           | not null |
+ name   | text    |           |          | ''::text

+1.
psql-ref.sgml(line 4085) needs to be modified. Otherwise, the patch
looks good to me.

--
Thanks & Regards,
Kuntal Ghosh
EnterpriseDB: http://www.enterprisedb.com

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#4Peter Eisentraut
peter_e@gmx.net
In reply to: Kuntal Ghosh (#3)
Re: split up psql \d Modifiers column

On 11/2/16 12:24 PM, Kuntal Ghosh wrote:

On Fri, Oct 28, 2016 at 9:00 AM, Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> wrote:

I propose to change the psql \d output a bit, best shown with an example:

\d persons3
-       Table "public.persons3"
- Column |  Type   |    Modifiers
---------+---------+------------------
- id     | integer | not null
- name   | text    | default ''::text
+              Table "public.persons3"
+ Column |  Type   | Collation | Nullable | Default
+--------+---------+-----------+----------+----------
+ id     | integer |           | not null |
+ name   | text    |           |          | ''::text

+1.
psql-ref.sgml(line 4085) needs to be modified. Otherwise, the patch
looks good to me.

Good catch. I didn't see that because it said "Modifier" instead of
"Modifiers". I also saw that the domain listing \dD also used
"Modifier", so I updated that as well to the new style. I have
committed the patch. Thanks for reviewing it.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers