aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2017-02-15 15:23:19 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2017-02-15 15:23:19 -0500
commita5d4e3ff79636a647a69e93ec8b9239703e9556a (patch)
tree51402ffb7023911641562fcbe610a30561c3c615
parent01e0cbc4f687325b825e7953f99f0b16a2bd4e96 (diff)
downloadpostgresql-a5d4e3ff79636a647a69e93ec8b9239703e9556a.tar.gz
postgresql-a5d4e3ff79636a647a69e93ec8b9239703e9556a.zip
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.
-rw-r--r--src/bin/psql/tab-complete.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 6e759d0b76f..94814c20d06 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 <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",