Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8a3e401

Browse files
committed
psql: Add tab completion for VACUUM and ANALYZE ... ONLY option.
Improve psql's tab completion for VACUUM and ANALYZE by supporting the ONLY option introduced in 62ddf7e. In passing, simplify some of the VACUUM patterns by making use of MatchAnyN. Author: Umar Hayat <postgresql.wizard@gmail.com> Reviewed-by: Vignesh C <vignesh21@gmail.com> Reviewed-by: Ilia Evdokimov <ilya.evdokimov@tantorlabs.com> Discussion: https://postgr.es/m/CAD68Dp3L6yW_nWs+MWBs6s8tKLRzXaQdQgVRm4byZe0L-hRD8g@mail.gmail.com
1 parent 2817525 commit 8a3e401

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

src/bin/psql/tab-complete.in.c

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3069,12 +3069,15 @@ match_previous_words(int pattern_id,
30693069
COMPLETE_WITH_QUERY(Query_for_list_of_roles);
30703070

30713071
/*
3072-
* ANALYZE [ ( option [, ...] ) ] [ table_and_columns [, ...] ]
3073-
* ANALYZE [ VERBOSE ] [ table_and_columns [, ...] ]
3072+
* ANALYZE [ ( option [, ...] ) ] [ [ ONLY ] table_and_columns [, ...] ]
3073+
* ANALYZE [ VERBOSE ] [ [ ONLY ] table_and_columns [, ...] ]
30743074
*/
30753075
else if (Matches("ANALYZE"))
30763076
COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_analyzables,
3077-
"VERBOSE");
3077+
"(", "VERBOSE", "ONLY");
3078+
else if (Matches("ANALYZE", "VERBOSE"))
3079+
COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_analyzables,
3080+
"ONLY");
30783081
else if (HeadMatches("ANALYZE", "(*") &&
30793082
!HeadMatches("ANALYZE", "(*)"))
30803083
{
@@ -5128,30 +5131,35 @@ match_previous_words(int pattern_id,
51285131
COMPLETE_WITH("OPTIONS");
51295132

51305133
/*
5131-
* VACUUM [ ( option [, ...] ) ] [ table_and_columns [, ...] ]
5132-
* VACUUM [ FULL ] [ FREEZE ] [ VERBOSE ] [ ANALYZE ] [ table_and_columns [, ...] ]
5134+
* VACUUM [ ( option [, ...] ) ] [ [ ONLY ] table_and_columns [, ...] ]
5135+
* VACUUM [ FULL ] [ FREEZE ] [ VERBOSE ] [ ANALYZE ] [ [ ONLY ] table_and_columns [, ...] ]
51335136
*/
51345137
else if (Matches("VACUUM"))
51355138
COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_vacuumables,
5139+
"(",
51365140
"FULL",
51375141
"FREEZE",
5142+
"VERBOSE",
51385143
"ANALYZE",
5139-
"VERBOSE");
5144+
"ONLY");
51405145
else if (Matches("VACUUM", "FULL"))
51415146
COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_vacuumables,
51425147
"FREEZE",
5148+
"VERBOSE",
51435149
"ANALYZE",
5144-
"VERBOSE");
5145-
else if (Matches("VACUUM", "FREEZE") ||
5146-
Matches("VACUUM", "FULL", "FREEZE"))
5150+
"ONLY");
5151+
else if (Matches("VACUUM", MatchAnyN, "FREEZE"))
51475152
COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_vacuumables,
51485153
"VERBOSE",
5149-
"ANALYZE");
5150-
else if (Matches("VACUUM", "VERBOSE") ||
5151-
Matches("VACUUM", "FULL|FREEZE", "VERBOSE") ||
5152-
Matches("VACUUM", "FULL", "FREEZE", "VERBOSE"))
5154+
"ANALYZE",
5155+
"ONLY");
5156+
else if (Matches("VACUUM", MatchAnyN, "VERBOSE"))
51535157
COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_vacuumables,
5154-
"ANALYZE");
5158+
"ANALYZE",
5159+
"ONLY");
5160+
else if (Matches("VACUUM", MatchAnyN, "ANALYZE"))
5161+
COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_vacuumables,
5162+
"ONLY");
51555163
else if (HeadMatches("VACUUM", "(*") &&
51565164
!HeadMatches("VACUUM", "(*)"))
51575165
{

0 commit comments

Comments
 (0)