diff options
author | Fujii Masao <fujii@postgresql.org> | 2016-02-01 22:19:51 +0900 |
---|---|---|
committer | Fujii Masao <fujii@postgresql.org> | 2016-02-01 22:19:51 +0900 |
commit | 89611c4dfa67630f7dcc25881c17cbd1b2e24ea1 (patch) | |
tree | 6fe14e4550e9bfb47c93168f8f4570be4ab2f018 | |
parent | 7a58d19b0c80300e7974620d336d5f90fe2d0087 (diff) | |
download | postgresql-89611c4dfa67630f7dcc25881c17cbd1b2e24ea1.tar.gz postgresql-89611c4dfa67630f7dcc25881c17cbd1b2e24ea1.zip |
Various fixes to "ALTER ... SET/RESET" tab completions
Add
- ALTER SYSTEM SET/RESET ... -> GUC variables
- ALTER TABLE ... SET WITH -> OIDS
- ALTER DATABASE/FUNCTION/ROLE/USER ... SET/RESET -> GUC variables
- ALTER DATABASE/FUNCTION/ROLE/USER ... SET ... -> FROM CURRENT/TO
- ALTER DATABASE/FUNCTION/ROLE/USER ... SET ... TO/= -> possible values
Author: Fujii Masao
Reviewed-by: Michael Paquier, Masahiko Sawada
-rw-r--r-- | src/bin/psql/tab-complete.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 008f3cbf46e..5f27120d832 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -1553,7 +1553,7 @@ psql_completion(const char *text, int start, int end) else if (Matches2("ALTER", "SYSTEM")) COMPLETE_WITH_LIST2("SET", "RESET"); /* ALTER SYSTEM SET|RESET <name> */ - else if (Matches4("ALTER", "SYSTEM", "SET|RESET", MatchAny)) + else if (Matches3("ALTER", "SYSTEM", "SET|RESET")) COMPLETE_WITH_QUERY(Query_for_list_of_alter_system_set_vars); /* ALTER VIEW <name> */ else if (Matches3("ALTER", "VIEW", MatchAny)) @@ -1754,6 +1754,9 @@ psql_completion(const char *text, int start, int end) */ else if (Matches5("ALTER", "TABLE", MatchAny, "SET", "TABLESPACE")) COMPLETE_WITH_QUERY(Query_for_list_of_tablespaces); + /* If we have ALTER TABLE <sth> SET WITH provide OIDS */ + else if (Matches5("ALTER", "TABLE", MatchAny, "SET", "WITH")) + COMPLETE_WITH_CONST("OIDS"); /* If we have ALTER TABLE <sth> SET WITHOUT provide CLUSTER or OIDS */ else if (Matches5("ALTER", "TABLE", MatchAny, "SET", "WITHOUT")) COMPLETE_WITH_LIST2("CLUSTER", "OIDS"); @@ -2702,7 +2705,7 @@ psql_completion(const char *text, int start, int end) /* SET, RESET, SHOW */ /* Complete with a variable name */ - else if (Matches1("SET|RESET")) + else if (TailMatches1("SET|RESET") && !TailMatches3("UPDATE", MatchAny, "SET")) COMPLETE_WITH_QUERY(Query_for_list_of_set_vars); else if (Matches1("SHOW")) COMPLETE_WITH_QUERY(Query_for_list_of_show_vars); @@ -2743,8 +2746,12 @@ psql_completion(const char *text, int start, int end) /* Complete SET <var> with "TO" */ else if (Matches2("SET", MatchAny)) COMPLETE_WITH_CONST("TO"); + /* Complete ALTER DATABASE|FUNCTION|ROLE|USER ... SET <name> */ + else if (HeadMatches2("ALTER", "DATABASE|FUNCTION|ROLE|USER") && + TailMatches2("SET", MatchAny)) + COMPLETE_WITH_LIST2("FROM CURRENT", "TO"); /* Suggest possible variable values */ - else if (Matches3("SET", MatchAny, "TO|=")) + else if (TailMatches3("SET", MatchAny, "TO|=")) { /* special cased code for individual GUCs */ if (TailMatches2("DateStyle", "TO|=")) |