Thread

  1. [PATCH v6 4/5] Improve tab completion for ALTER SYSTEM RESET

    Dagfinn Ilmari Mannsåker <ilmari@ilmari.org> — 2025-08-08T22:07:39Z

    Only complete variables where sourcefile is `postgresql.conf.auto` in
    the data directory.
    ---
     src/bin/psql/tab-complete.in.c | 11 +++++++++--
     1 file changed, 9 insertions(+), 2 deletions(-)
    
    diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c
    index 3afc3a24231..156fef50085 100644
    --- a/src/bin/psql/tab-complete.in.c
    +++ b/src/bin/psql/tab-complete.in.c
    @@ -1062,6 +1062,11 @@ static const SchemaQuery Query_for_trigger_of_table = {
     " WHERE context != 'internal' "\
     "   AND pg_catalog.lower(name) LIKE pg_catalog.lower('%s')"
     
    +#define Query_for_list_of_alter_system_reset_vars \
    +"SELECT pg_catalog.lower(name) FROM pg_catalog.pg_settings " \
    +" WHERE sourcefile ~ '[\\\\/]postgresql\\.auto\\.conf$' " \
    +"   AND pg_catalog.lower(name) LIKE pg_catalog.lower('%s')"
    +
     #define Query_for_list_of_set_vars \
     "SELECT pg_catalog.lower(name) FROM pg_catalog.pg_settings "\
     " WHERE context IN ('user', 'superuser') "\
    @@ -2647,8 +2652,10 @@ match_previous_words(int pattern_id,
     	/* ALTER SYSTEM SET, RESET, RESET ALL */
     	else if (Matches("ALTER", "SYSTEM"))
     		COMPLETE_WITH("SET", "RESET");
    -	else if (Matches("ALTER", "SYSTEM", "SET|RESET"))
    -		COMPLETE_WITH_QUERY_VERBATIM_PLUS(Query_for_list_of_alter_system_set_vars,
    +	else if (Matches("ALTER", "SYSTEM", "SET"))
    +		COMPLETE_WITH_QUERY_VERBATIM(Query_for_list_of_alter_system_set_vars);
    +	else if (Matches("ALTER", "SYSTEM", "RESET"))
    +		COMPLETE_WITH_QUERY_VERBATIM_PLUS(Query_for_list_of_alter_system_reset_vars,
     										  "ALL");
     	else if (Matches("ALTER", "SYSTEM", "SET", MatchAny))
     		COMPLETE_WITH("TO");
    -- 
    2.51.2
    
    
    --=-=-=
    Content-Type: text/x-diff
    Content-Disposition: inline;
     filename=v6-0005-Improve-tab-completion-for-ALTER-SYSTEM-SET-RESET.patch