From: | Vik Fearing <vik(dot)fearing(at)2ndquadrant(dot)com> |
---|---|
To: | Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: \describe* |
Date: | 2018-01-26 01:58:09 |
Message-ID: | 474c19bf-cd35-5e93-537e-d3b4712978da@2ndquadrant.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 01/26/2018 02:11 AM, Corey Huinker wrote:
> Some of the discussions about making psql more user friendly (more tab
> completions help, exit, etc) got me thinking about other ways that psql
> could be more friendly, and the one that comes to mind is our terse but
> cryptic \d* commands.
>
> I think it would be helpful and instructive to have corresponding
> long-form describe commands.
>
> Take describing schemas. Is \dn intuitive? Not really. In hindsight, you
> may think "yeah, a schema is a namespace", but you never guessed 'n' on
> the first try, or the second.
At first blush, I support this idea.
> Looking over exec_command_d() a bit, I think it's a bit of a stretch do
> have each command handle a long form like this:
>
> \describe table my_table
> or
> \describe table verbose my_table
>
> because then each \d-variant has to account for objects named "table"
> and "verbose" and that's a path to unhappiness.
We're already being verbose so we can easily require
\describe table table
for the first case, and if you move "verbose" to before the object, then
we can have
\describe verbose table verbose
So basically, the grammar would be "\describe [verbose] [system] object
name" instead of "\dXS[+] name" where X is the object.
One thing not addressed here is a long version of \ditvS+. Maybe
something like
\describe verbose system index, table, view <pattern>
> But if we dash-separated them, then all of the strcmps would be in the
> 'e' subsection, and each one would just have to know it's long to short
> translation, and call exec_command_d with the corresponding short command
>
> describe => d
> describe-verbose => d+
> describe-aggregates-verbose => da+
> describe-roles => du
-1
> We could even presume the verbose flag in all cases (after all, the user
> was being verbose...), which would also cut down on tab-completion
> results, and we could check for interactive mode and display a message like
>
> \describe-schemas (short: \dn+)
>
> so that the person has the opportunity to learn the corresponding short
> command.
-1 on this, too.
If we presume "verbose", we need to add a "terse". If the user is
interested in the short forms, they can issue a \? like everybody else.
> In additional to aiding tab completion discovery of the commands (i.e.
> typing "\desc" and then hitting tab, it would also make scripts a little
> more self-documenting.
I always use long versions of options when writing scripts specifically
because they are self-documenting (see 0be22457d7) so I certainly
support this argument.
Note: I am not volunteering to implement any of this, but I'll happily
review it.
--
Vik Fearing +33 6 46 75 15 36
http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support
From | Date | Subject | |
---|---|---|---|
Next Message | Stephen Frost | 2018-01-26 02:28:13 | Re: [HACKERS] REINDEX CONCURRENTLY 2.0 |
Previous Message | Tsunakawa, Takayuki | 2018-01-26 01:54:04 | RE: [HACKERS][PATCH] Applying PMDK to WAL operations for persistent memory |