aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2020-09-17 11:49:29 +0900
committerMichael Paquier <michael@paquier.xyz>2020-09-17 11:49:29 +0900
commit7307df16a05984396649db33df0faf6d840cd223 (patch)
tree6ae3d1eff8e99a58413b4c14e3b631c60ba89cb3 /src
parentbabef40c9a999949abe0ae8e82240cac3f154237 (diff)
downloadpostgresql-7307df16a05984396649db33df0faf6d840cd223.tar.gz
postgresql-7307df16a05984396649db33df0faf6d840cd223.zip
Improve tab completion of IMPORT FOREIGN SCHEMA in psql
It is not possible to get a list of foreign schemas as the server is not known, so this provides instead a list of local schemas, which is more useful than nothing if using a loopback server or having schema names matching in the local and remote servers. Author: Jeff Janes Reviewed-by: Tom Lane, Michael Paquier Discussion: https://postgr.es/m/CAMkU=1wr7Roj41q-XiJs=Uyc2xCmHhcGGy7J-peJQK-e+w=ghw@mail.gmail.com
Diffstat (limited to 'src')
-rw-r--r--src/bin/psql/tab-complete.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index f41785f11c1..9c6f5ecb6a8 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -3293,6 +3293,17 @@ psql_completion(const char *text, int start, int end)
COMPLETE_WITH("FOREIGN SCHEMA");
else if (Matches("IMPORT", "FOREIGN"))
COMPLETE_WITH("SCHEMA");
+ else if (Matches("IMPORT", "FOREIGN", "SCHEMA", MatchAny))
+ COMPLETE_WITH("EXCEPT (", "FROM SERVER", "LIMIT TO (");
+ else if (TailMatches("LIMIT", "TO", "(*)") ||
+ TailMatches("EXCEPT", "(*)"))
+ COMPLETE_WITH("FROM SERVER");
+ else if (TailMatches("FROM", "SERVER", MatchAny))
+ COMPLETE_WITH("INTO");
+ else if (TailMatches("FROM", "SERVER", MatchAny, "INTO"))
+ COMPLETE_WITH_QUERY(Query_for_list_of_schemas);
+ else if (TailMatches("FROM", "SERVER", MatchAny, "INTO", MatchAny))
+ COMPLETE_WITH("OPTIONS (");
/* INSERT --- can be inside EXPLAIN, RULE, etc */
/* Complete INSERT with "INTO" */