Hi,
Here is a patch which adds the below missing tab completions for the FDW
DDL commands. I noticed these were missing while playing around with
FDWs a while ago.
"ALTER SERVER <name>" with "RENAME TO"
"CREATE SERVER <name> FOREIGN DATA WRAPPER" with fdw name
"CREATE|ALTER USER MAPPING FOR <name> SERVER <name>" with "OPTIONS ("
Another completion which is currently missing but I am not sure if we
should add or not is completing "ALTER|CREATE|DROP USER" with "MAPPING
FOR", but since it might interfere with completing to username for
"ALTER|DROP USER" I am not sure we want it. What do you think?
Andreas
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 4c93ae9..46b555c 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -1444,7 +1444,7 @@ psql_completion(const char *text, int start, int end)
COMPLETE_WITH_LIST3("MINVALUE", "MAXVALUE", "CYCLE");
/* ALTER SERVER <name> */
else if (TailMatches3("ALTER", "SERVER", MatchAny))
- COMPLETE_WITH_LIST3("VERSION", "OPTIONS", "OWNER TO");
+ COMPLETE_WITH_LIST4("VERSION", "OPTIONS", "OWNER TO", "RENAME TO");
/* ALTER SYSTEM SET, RESET, RESET ALL */
else if (TailMatches2("ALTER", "SYSTEM"))
COMPLETE_WITH_LIST2("SET", "RESET");
@@ -2015,8 +2015,12 @@ psql_completion(const char *text, int start, int end)
COMPLETE_WITH_LIST3("MINVALUE", "MAXVALUE", "CYCLE");
/* CREATE SERVER <name> */
+ /* Complete "CREATE SERVER <name>" with "FOREIGN DATA WRAPPER" */
else if (TailMatches3("CREATE", "SERVER", MatchAny))
COMPLETE_WITH_LIST3("TYPE", "VERSION", "FOREIGN DATA WRAPPER");
+ /* Complete "CREATE SERVER <name> FOREIGN DATA WRAPPER" with fdw name */
+ else if (TailMatches6("CREATE", "SERVER", MatchAny, "FOREIGN", "DATA", "WRAPPER"))
+ COMPLETE_WITH_QUERY(Query_for_list_of_fdws);
/* CREATE TABLE */
/* Complete "CREATE TEMP/TEMPORARY" with the possible temp objects */
@@ -2740,6 +2744,8 @@ psql_completion(const char *text, int start, int end)
COMPLETE_WITH_QUERY(Query_for_list_of_user_mappings);
else if (TailMatches5("CREATE|ALTER|DROP", "USER", "MAPPING", "FOR", MatchAny))
COMPLETE_WITH_CONST("SERVER");
+ else if (TailMatches7("CREATE|ALTER", "USER", "MAPPING", "FOR", MatchAny, "SERVER", MatchAny))
+ COMPLETE_WITH_CONST("OPTIONS (");
/*
* VACUUM [ FULL | FREEZE ] [ VERBOSE ] [ table ]
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers