Thread

  1. [PATCH] psql: Fix tab completion for VACUUM option values

    Yugo Nagata <nagata@sraoss.co.jp> — 2025-12-22T16:28:10Z

    Commit 8a3e4011 introduced tab completion for the ONLY option of VACUUM
    and ANALYZE, along with some code simplification using MatchAnyN.
    However, it broke tab completion for VACUUM option values. For example,
    neither ON nor OFF is suggested after "VACUUM (VERBOSE".
    
    In addition, tab completion for the ONLY option is insufficient, and it
    is not suggested immediately after a completed option list. This commit
    fixes these issues.
    ---
     src/bin/psql/tab-complete.in.c | 42 +++++++++++++++++++---------------
     1 file changed, 24 insertions(+), 18 deletions(-)
    
    diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c
    index b1ff6f6cd94..254b0af5cf5 100644
    --- a/src/bin/psql/tab-complete.in.c
    +++ b/src/bin/psql/tab-complete.in.c
    @@ -3170,6 +3170,9 @@ match_previous_words(int pattern_id,
     		else if (TailMatches("VERBOSE|SKIP_LOCKED"))
     			COMPLETE_WITH("ON", "OFF");
     	}
    +	else if (Matches("ANALYZE", "(*)"))
    +		COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_analyzables,
    +										"ONLY");
     	else if (Matches("ANALYZE", MatchAnyN, "("))
     		/* "ANALYZE (" should be caught above, so assume we want columns */
     		COMPLETE_WITH_ATTR(prev2_wd);
    @@ -5283,24 +5286,6 @@ match_previous_words(int pattern_id,
     										"VERBOSE",
     										"ANALYZE",
     										"ONLY");
    -	else if (Matches("VACUUM", "FULL"))
    -		COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_vacuumables,
    -										"FREEZE",
    -										"VERBOSE",
    -										"ANALYZE",
    -										"ONLY");
    -	else if (Matches("VACUUM", MatchAnyN, "FREEZE"))
    -		COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_vacuumables,
    -										"VERBOSE",
    -										"ANALYZE",
    -										"ONLY");
    -	else if (Matches("VACUUM", MatchAnyN, "VERBOSE"))
    -		COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_vacuumables,
    -										"ANALYZE",
    -										"ONLY");
    -	else if (Matches("VACUUM", MatchAnyN, "ANALYZE"))
    -		COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_vacuumables,
    -										"ONLY");
     	else if (HeadMatches("VACUUM", "(*") &&
     			 !HeadMatches("VACUUM", "(*)"))
     	{
    @@ -5320,6 +5305,27 @@ match_previous_words(int pattern_id,
     		else if (TailMatches("INDEX_CLEANUP"))
     			COMPLETE_WITH("AUTO", "ON", "OFF");
     	}
    +	else if (Matches("VACUUM", "(*)"))
    +		COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_vacuumables,
    +										"ONLY");
    +	else if (Matches("VACUUM", "FULL"))
    +		COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_vacuumables,
    +										"FREEZE",
    +										"VERBOSE",
    +										"ANALYZE",
    +										"ONLY");
    +	else if (Matches("VACUUM", MatchAnyN, "FREEZE"))
    +		COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_vacuumables,
    +										"VERBOSE",
    +										"ANALYZE",
    +										"ONLY");
    +	else if (Matches("VACUUM", MatchAnyN, "VERBOSE"))
    +		COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_vacuumables,
    +										"ANALYZE",
    +										"ONLY");
    +	else if (Matches("VACUUM", MatchAnyN, "ANALYZE"))
    +		COMPLETE_WITH_SCHEMA_QUERY_PLUS(Query_for_list_of_vacuumables,
    +										"ONLY");
     	else if (Matches("VACUUM", MatchAnyN, "("))
     		/* "VACUUM (" should be caught above, so assume we want columns */
     		COMPLETE_WITH_ATTR(prev2_wd);
    -- 
    2.43.0
    
    
    --Multipart=_Tue__23_Dec_2025_02_15_09_+0900_w7IIQhTcBAD=40BI--