Re: [HACKERS] \h tab-completion - Mailing list pgsql-hackers

From Kyotaro HORIGUCHI
Subject Re: [HACKERS] \h tab-completion
Date
Msg-id 20170302.133622.176781001.horiguchi.kyotaro@lab.ntt.co.jp
Whole thread Raw
In response to Re: [HACKERS] \h tab-completion  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
List pgsql-hackers
Hello,

At Wed, 1 Mar 2017 08:47:15 -0500, Peter Eisentraut <peter.eisentraut@2ndquadrant.com> wrote in
<ceaf1188-5d7d-a8e1-19aa-8184b5923072@2ndquadrant.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





pgsql-hackers by date:

Previous
From: Noah Misch
Date:
Subject: Re: [HACKERS] SerializedSnapshotData alignment
Next
From: Ashutosh Bapat
Date:
Subject: Re: [HACKERS] Partition-wise join for join between (declaratively)partitioned tables