Patch by request at pgcon

Started by Bruce Momjianalmost 15 years ago7 messageshackers
Jump to latest
#1Bruce Momjian
bruce@momjian.us

A user at Pgcon made a pretty convincing case that it would sometimes
be handy to be able to see a list of columns in alphabetical order in
psql's \dt output. This is especially true when there are a very large
number of columns and you're looking for a specific column with name
matching some pattern in your head. Whie you could use your pager's
search feature, people are also quite accustomed to visually searching
for strings in sorted lists so that's a natural solution.

Adding such a feature would be pretty trivial, attached is a patch.

--
greg

Attachments:

psql-sorted-attributes.difftext/x-patch; charset=US-ASCII; name=psql-sorted-attributes.diffDownload+41-39
#2Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Bruce Momjian (#1)
Re: Patch by request at pgcon

Excerpts from Greg Stark's message of jue may 19 12:11:29 -0400 2011:

A user at Pgcon made a pretty convincing case that it would sometimes
be handy to be able to see a list of columns in alphabetical order in
psql's \dt output. This is especially true when there are a very large
number of columns and you're looking for a specific column with name
matching some pattern in your head. Whie you could use your pager's
search feature, people are also quite accustomed to visually searching
for strings in sorted lists so that's a natural solution.

Adding such a feature would be pretty trivial, attached is a patch.

Interesting, but not so trivial I think -- I mean if you're doing this I
think you should add a column with the nominal position of the column in
the table, so that it enables you to find it quickly in the other sort
order.

--
Álvaro Herrera <alvherre@commandprompt.com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

#3Stephen Frost
sfrost@snowman.net
In reply to: Alvaro Herrera (#2)
Re: Patch by request at pgcon

* Alvaro Herrera (alvherre@commandprompt.com) wrote:

Excerpts from Greg Stark's message of jue may 19 12:11:29 -0400 2011:

Adding such a feature would be pretty trivial, attached is a patch.

Interesting, but not so trivial I think -- I mean if you're doing this I
think you should add a column with the nominal position of the column in
the table, so that it enables you to find it quickly in the other sort
order.

Afraid that I have to disagree.. The attnum (or, really, worse, since
you'd have to actually count/number the non-dropped columns only..)
doesn't strike me as being useful to the user for much of anything,
especially since we don't have the number anywhere in the default
listing.

Thanks,

Stephen

#4Stephen Frost
sfrost@snowman.net
In reply to: Bruce Momjian (#1)
Re: Patch by request at pgcon

* Greg Stark (stark@mit.edu) wrote:

Adding such a feature would be pretty trivial, attached is a patch.

Quick code-only review: sortedAttrs is a horrible var name for what it
is. More like 'sortbyName' would make more sense, at least to me.
Also, no regression test..? :) The interface looks alright to me,
though I wonder for a moment if this might be a \set option. Are there
other things which could be sorted differently based on such an
option..? If not, then perhaps another char for \dt is right.

Thanks,

Stephen

#5Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Stephen Frost (#3)
Re: Patch by request at pgcon

Excerpts from Stephen Frost's message of jue may 19 13:49:33 -0400 2011:

* Alvaro Herrera (alvherre@commandprompt.com) wrote:

Excerpts from Greg Stark's message of jue may 19 12:11:29 -0400 2011:

Adding such a feature would be pretty trivial, attached is a patch.

Interesting, but not so trivial I think -- I mean if you're doing this I
think you should add a column with the nominal position of the column in
the table, so that it enables you to find it quickly in the other sort
order.

Afraid that I have to disagree.. The attnum (or, really, worse, since
you'd have to actually count/number the non-dropped columns only..)
doesn't strike me as being useful to the user for much of anything,
especially since we don't have the number anywhere in the default
listing.

Well, counting is not that hard (I mean if there's more than a
screenful, just watch the pager). But yeah, it's not the attnum.

--
Álvaro Herrera <alvherre@commandprompt.com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

#6Bruce Momjian
bruce@momjian.us
In reply to: Stephen Frost (#4)
Re: Patch by request at pgcon

On Thu, May 19, 2011 at 1:53 PM, Stephen Frost <sfrost@snowman.net> wrote:

Quick code-only review: sortedAttrs is a horrible var name for what it
is.  More like 'sortbyName' would make more sense, at least to me.
Also, no regression test..? :)

Do we have regression tests for psql \ commands?

--
greg

#7Stephen Frost
sfrost@snowman.net
In reply to: Bruce Momjian (#6)
Re: Patch by request at pgcon

* Greg Stark (stark@mit.edu) wrote:

On Thu, May 19, 2011 at 1:53 PM, Stephen Frost <sfrost@snowman.net> wrote:

Quick code-only review: sortedAttrs is a horrible var name for what it
is.  More like 'sortbyName' would make more sense, at least to me.
Also, no regression test..? :)

Do we have regression tests for psql \ commands?

There's certainly lots of usage of psql \ commands in the regression
tests, though we don't have a dedicated "test psql \ commands"
regression suite. Suppose it's a toss-up on if we should add this/other
ones. My comment was more toungue-in-cheek as I stressed regression
tests in my talk this morning. :)

Stephen