From f88737801f84589611e767ebcd1d315f383ea2cf Mon Sep 17 00:00:00 2001 From: Umar Hayat Date: Thu, 6 Feb 2025 19:44:16 +0900 Subject: [PATCH v3] psql: Tab completion for VACUUM and ANALYZE ... ONLY option Improve psql tab completion for VACUUM and ANALYZE with ONLY option introduced in 62ddf7e Author: Umar Hayat Reviewed-by: Vignesh C Reviewed-by: Ilia Evdokimov Discussion: https://www.postgresql.org/message-id/CAD68Dp3L6yW_nWs%2BMWBs6s8tKLRzXaQdQgVRm4byZe0L-hRD8g%40mail.gmail.com --- src/bin/psql/tab-complete.in.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 9a4d993e2bc..b2db8fc9556 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -3069,12 +3069,14 @@ match_previous_words(int pattern_id, COMPLETE_WITH_QUERY(Query_for_list_of_roles); /* - * ANALYZE [ ( option [, ...] ) ] [ table_and_columns [, ...] ] - * ANALYZE [ VERBOSE ] [ table_and_columns [, ...] ] + * ANALYZE [ ( option [, ...] ) ] [ [ONLY] table_and_columns [, ...] ] + * ANALYZE [ VERBOSE ] [ [ONLY] table_and_columns [, ...] ] */ else if (Matches("ANALYZE")) COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_analyzables, - "VERBOSE"); + "VERBOSE", "ONLY", "("); + else if (Matches("ANALYZE", "VERBOSE")) + COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_analyzables, "ONLY"); else if (HeadMatches("ANALYZE", "(*") && !HeadMatches("ANALYZE", "(*)")) { @@ -5128,30 +5130,39 @@ match_previous_words(int pattern_id, COMPLETE_WITH("OPTIONS"); /* - * VACUUM [ ( option [, ...] ) ] [ table_and_columns [, ...] ] - * VACUUM [ FULL ] [ FREEZE ] [ VERBOSE ] [ ANALYZE ] [ table_and_columns [, ...] ] + * VACUUM [ ( option [, ...] ) ] [ [ONLY] table_and_columns [, ...] ] + * VACUUM [ FULL ] [ FREEZE ] [ VERBOSE ] [ ANALYZE ] [ [ONLY] table_and_columns [, ...] ] */ else if (Matches("VACUUM")) COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_vacuumables, "FULL", "FREEZE", "ANALYZE", - "VERBOSE"); + "VERBOSE", + "ONLY", + "("); else if (Matches("VACUUM", "FULL")) COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_vacuumables, "FREEZE", "ANALYZE", - "VERBOSE"); + "VERBOSE", + "ONLY"); + else if (Matches("VACUUM", "ANALYZE") || + Matches("VACUUM", "VERBOSE", "ANALYZE")) + COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_vacuumables, + "ONLY"); else if (Matches("VACUUM", "FREEZE") || Matches("VACUUM", "FULL", "FREEZE")) COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_vacuumables, "VERBOSE", - "ANALYZE"); + "ANALYZE", + "ONLY"); else if (Matches("VACUUM", "VERBOSE") || Matches("VACUUM", "FULL|FREEZE", "VERBOSE") || Matches("VACUUM", "FULL", "FREEZE", "VERBOSE")) COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_vacuumables, - "ANALYZE"); + "ANALYZE", + "ONLY"); else if (HeadMatches("VACUUM", "(*") && !HeadMatches("VACUUM", "(*)")) { -- 2.43.0