Re: adding tab completions

Edmund Horner <ejrh00@gmail.com>

From: Edmund Horner <ejrh00@gmail.com>
To: Justin Pryzby <pryzby@telsasoft.com>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2018-05-29T12:45:30Z
Lists: 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


Commits

  1. Improve tab completion for ANALYZE, EXPLAIN, and VACUUM.

  2. Minor fixes for psql tab completion.

  3. Add parenthesized options syntax for ANALYZE.

  4. Don't allow VACUUM VERBOSE ANALYZE VERBOSE.

  5. Parameter toast_tuple_target controls TOAST for new rows

  6. Add hash partitioning.

  7. Allow multiple tables to be specified in one VACUUM or ANALYZE command.

  8. Don't uselessly rewrite, truncate, VACUUM, or ANALYZE partitioned tables.

  9. Remove deprecated COMMENT ON RULE syntax

  10. Add VACUUM (DISABLE_PAGE_SKIPPING) for emergencies.

  11. Extend EXPLAIN to allow generic options to be specified.