From a5d4e3ff79636a647a69e93ec8b9239703e9556a Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 15 Feb 2017 15:23:19 -0500 Subject: [PATCH] Fix tab completion for "ALTER SYSTEM SET variable ...". It wouldn't complete "TO" after the variable name, which is certainly minor enough. But since we do complete "TO" after "SET variable ...", and since this case used to work pre-9.6, I think this is a bug. Also, fix the query used to collect the variable names; whoever last touched it evidently didn't understand how the pieces are supposed to fit together. It accidentally worked anyway, because readline ignores irrelevant completions, but it was randomly unlike the ones around it, and could be a source of actual bugs if someone copied it as a prototype for another query. --- src/bin/psql/tab-complete.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 6e759d0b76..94814c20d0 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -675,9 +675,9 @@ static const SchemaQuery Query_for_list_of_matviews = { #define Query_for_list_of_alter_system_set_vars \ "SELECT name FROM "\ " (SELECT pg_catalog.lower(name) AS name FROM pg_catalog.pg_settings "\ -" WHERE context != 'internal') ss "\ -" WHERE substring(name,1,%d)='%s'"\ -" UNION ALL SELECT 'all' ss" +" WHERE context != 'internal' "\ +" UNION ALL SELECT 'all') ss "\ +" WHERE substring(name,1,%d)='%s'" #define Query_for_list_of_set_vars \ "SELECT name FROM "\ @@ -1661,9 +1661,10 @@ psql_completion(const char *text, int start, int end) /* ALTER SYSTEM SET, RESET, RESET ALL */ else if (Matches2("ALTER", "SYSTEM")) COMPLETE_WITH_LIST2("SET", "RESET"); - /* ALTER SYSTEM SET|RESET */ else if (Matches3("ALTER", "SYSTEM", "SET|RESET")) COMPLETE_WITH_QUERY(Query_for_list_of_alter_system_set_vars); + else if (Matches4("ALTER", "SYSTEM", "SET", MatchAny)) + COMPLETE_WITH_CONST("TO"); /* ALTER VIEW */ else if (Matches3("ALTER", "VIEW", MatchAny)) COMPLETE_WITH_LIST4("ALTER COLUMN", "OWNER TO", "RENAME TO", -- 2.40.0