Re: adding tab completions

From: Edmund Horner <ejrh00(at)gmail(dot)com>
To: Justin Pryzby <pryzby(at)telsasoft(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: adding tab completions
Date: 2018-05-29 12:45:30
Message-ID: CAMyN-kDUKKtaZRQJu_-ahr258b1P0PC341xyH0CK3CWi7fet7g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 29 May 2018 at 12:06, Justin Pryzby <pryzby(at)telsasoft(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Edmund Horner 2018-05-29 12:58:07 Redundant psql tab-completion for CREATE PUBLICATION
Previous Message Arturas Mazeika 2018-05-29 12:15:08 pgAgent: ERROR: Couldn't register event handle.