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.
This commit is contained in:
Tom Lane 2017-02-15 15:23:19 -05:00
parent 01e0cbc4f6
commit a5d4e3ff79
1 changed files with 5 additions and 4 deletions

View File

@ -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 <name> */
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 <name> */
else if (Matches3("ALTER", "VIEW", MatchAny))
COMPLETE_WITH_LIST4("ALTER COLUMN", "OWNER TO", "RENAME TO",