Re: \h tab-completion

From: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
To: peter(dot)eisentraut(at)2ndquadrant(dot)com
Cc: andreas(at)proxel(dot)se, michael(dot)paquier(at)gmail(dot)com, memissemerson(at)gmail(dot)com, sfrost(at)snowman(dot)net, pgsql-hackers(at)postgresql(dot)org
Subject: Re: \h tab-completion
Date: 2017-03-02 04:36:22
Message-ID: 20170302.133622.176781001.horiguchi.kyotaro@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

At Wed, 1 Mar 2017 08:47:15 -0500, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com> wrote in <ceaf1188-5d7d-a8e1-19aa-8184b5923072(at)2ndquadrant(dot)com>
> On 2/3/17 07:12, Andreas Karlsson wrote:
> > On 01/25/2017 07:13 AM, Michael Paquier wrote:
> >> What I think you should do is making the code path of
> >> \\h smarter with some exceptions by using TailMatchesCS2() for ALTER.
> >> There is as well the case of DROP commands that should be treated by
> >> the way.
> >
> > Yes, I think that is correct approach. I have attached a patch where I
> > add completion for \h ALTER and \h DROP.
>
> Instead of creating another copy of list_ALTER, let's use the
> words_after_create list and write a version of
> create_command_generator/drop_command_generator.

I'd like to separate the completion code into context-detector
and completion-engine. The former returns a "perse context value"
and the latter shows the suggestions from the values. Help engine
can use the same context-detector with the completion code. But
the correspondence between the two routines seems hardly
maintained:( (and such separation(refactoring) will be stuck on
the way)

Even this is a bit different topic from this patch aims, another
random thought on the help is that \h command should offer the
restriction words instead of all documents of possiblly-matching
(or head-matching) commands. For example, the current \h command
shows the following for create command.

=# \h create<cr>
Command: CREATE ACCESS METHOD
Description: define a new access method
Syntax:
CREATE ACCESS METHOD name
TYPE access_method_type
HANDLER handler_function

Command: CREATE AGGREGATE
...

This seems pointless to me and should offer the list of the next
words and short summary. gdb does the following for the case the
following.

| (gdb) help enable
| Enable some breakpoints.
| Give breakpoint numbers (separated by spaces) as arguments.
| With no subcommand, breakpoints are enabled until you command otherwise.
| This is used to cancel the effect of the "disable" command.
| With a subcommand you can enable temporarily.
|
| List of enable subcommands:
|
| enable breakpoints -- Enable some breakpoints
| enable count -- Enable breakpoints for COUNT hits
| enable delete -- Enable breakpoints and delete when hit

| =# \h create<cr>
| Define an object
|
| List of create subcommands:
|
| CREATE ACCESS METHOD - Define a new access method
| CREATE AGGREGATE - Define a new aggregate function
| ...

One bothersome problem is distinction between "CREATE TABLE" and
("CREATE TABLE AS" and "CREATE TABLESPACE"), but this might be
resolved by a small craft in documentation.

| - Documentation for "CREATE TABLE"
| Define a table
|
| You might want to see the following commands.
| CREATE TABLE AS - Define a new table from the result of a query
| CREATE TABLESPACE - Define a new tablespace.
|
| Syntax:
| CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXISTS ] %s ( [

regards,

--
Kyotaro Horiguchi
NTT Open Source Software Center

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Ashutosh Bapat 2017-03-02 04:52:58 Re: Partition-wise join for join between (declaratively) partitioned tables
Previous Message Noah Misch 2017-03-02 04:02:20 Re: SerializedSnapshotData alignment