Re: adding tab completions - Mailing list pgsql-hackers

From Edmund Horner
Subject Re: adding tab completions
Date
Msg-id CAMyN-kDUKKtaZRQJu_-ahr258b1P0PC341xyH0CK3CWi7fet7g@mail.gmail.com
Whole thread Raw
In response to adding tab completions  (Justin Pryzby <pryzby@telsasoft.com>)
Responses Re: adding tab completions
List pgsql-hackers
On 29 May 2018 at 12:06, Justin Pryzby <pryzby@telsasoft.com> wrote:
> Find attached tab completion for the following:
>
> "... Also, recursively perform VACUUM and ANALYZE on partitions when the
> command is applied to a partitioned table."
> 3c3bb99330aa9b4c2f6258bfa0265d806bf365c3
>
> Add parenthesized options syntax for ANALYZE.
> 854dd8cff523bc17972d34772b0e39ad3d6d46a4
>
> Add VACUUM (DISABLE_PAGE_SKIPPING) for emergencies.
> ede62e56fbe809baa1a7bc3873d82f12ffe7540b
>
> Allow multiple tables to be specified in one VACUUM or ANALYZE command.
> 11d8d72c27a64ea4e30adce11cf6c4f3dd3e60db

Hi Justin,

I don't believe it's meaningful to match on words with spaces in them,
for instance, in

    else if (Matches3("VACUUM", "FULL|FREEZE|FULL FREEZE", "ANALYZE")) {

as there will never be a word called "FULL FREEZE" (the tab completion
logic splits using spaces, though it will keep things in quotes and
parentheses together).

I don't know what the best approach is for cases like VACUUM, where
there are multiple optional words.  Maybe something like the
following?  It's pretty ugly, but then, it is part of the tab
completion logic; a good sense of compromise is needed there.

    else if (Matches1("VACUUM"))
        COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tpmf,
                                   " UNION SELECT 'FULL'"
                                   " UNION SELECT 'FREEZE'"
                                   " UNION SELECT 'VERBOSE'"
                                   " UNION SELECT 'ANALYZE'"
                                   " UNION SELECT '('");
    else if (HeadMatches1("VACUUM") && TailMatches1("FULL"))
        COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tpmf,
                                   " UNION SELECT 'FREEZE'"
                                   " UNION SELECT 'VERBOSE'"
                                   " UNION SELECT 'ANALYZE'");
    else if (HeadMatches1("VACUUM") && TailMatches1("FREEZE"))
        COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tpmf,
                                   " UNION SELECT 'VERBOSE'"
                                   " UNION SELECT 'ANALYZE'");
    else if (HeadMatches1("VACUUM") && TailMatches1("VERBOSE"))
        COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tpmf,
                                   " UNION SELECT 'ANALYZE'");

(Not a patch file, so that you don't have to merge it with the rest of
your patch. ;-) )

Cheers,
Edmund


pgsql-hackers by date:

Previous
From: Arturas Mazeika
Date:
Subject: pgAgent: ERROR: Couldn't register event handle.
Next
From: Edmund Horner
Date:
Subject: Redundant psql tab-completion for CREATE PUBLICATION