Thread: Patch by request at pgcon

Patch by request at pgcon

From
Greg Stark
Date:
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

Attachment

Re: Patch by request at pgcon

From
Alvaro Herrera
Date:
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


Re: Patch by request at pgcon

From
Stephen Frost
Date:
* 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

Re: Patch by request at pgcon

From
Stephen Frost
Date:
* 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

Re: Patch by request at pgcon

From
Alvaro Herrera
Date:
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


Re: Patch by request at pgcon

From
Greg Stark
Date:
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


Re: Patch by request at pgcon

From
Stephen Frost
Date:
* 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