Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 6ae4c8d

Browse files
committed
psql: Improve completion of FDW DDL commands
Add - ALTER FOREIGN DATA WRAPPER -> RENAME TO - ALTER SERVER -> RENAME TO - ALTER SERVER ... VERSION ... -> OPTIONS - CREATE FOREIGN DATA WRAPPER -> OPTIONS - CREATE SERVER -> OPTIONS - CREATE|ALTER USER MAPPING -> OPTIONS From: Andreas Karlsson <andreas@proxel.se>
1 parent df43fcf commit 6ae4c8d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/bin/psql/tab-complete.c

+12-3
Original file line numberDiff line numberDiff line change
@@ -1417,7 +1417,7 @@ psql_completion(const char *text, int start, int end)
14171417

14181418
/* ALTER FOREIGN DATA WRAPPER <name> */
14191419
else if (Matches5("ALTER", "FOREIGN", "DATA", "WRAPPER", MatchAny))
1420-
COMPLETE_WITH_LIST4("HANDLER", "VALIDATOR", "OPTIONS", "OWNER TO");
1420+
COMPLETE_WITH_LIST5("HANDLER", "VALIDATOR", "OPTIONS", "OWNER TO", "RENAME TO");
14211421

14221422
/* ALTER FOREIGN TABLE <name> */
14231423
else if (Matches4("ALTER", "FOREIGN", "TABLE", MatchAny))
@@ -1544,7 +1544,10 @@ psql_completion(const char *text, int start, int end)
15441544
COMPLETE_WITH_LIST3("MINVALUE", "MAXVALUE", "CYCLE");
15451545
/* ALTER SERVER <name> */
15461546
else if (Matches3("ALTER", "SERVER", MatchAny))
1547-
COMPLETE_WITH_LIST3("VERSION", "OPTIONS", "OWNER TO");
1547+
COMPLETE_WITH_LIST4("VERSION", "OPTIONS", "OWNER TO", "RENAME TO");
1548+
/* ALTER SERVER <name> VERSION <version>*/
1549+
else if (Matches5("ALTER", "SERVER", MatchAny, "VERSION", MatchAny))
1550+
COMPLETE_WITH_CONST("OPTIONS");
15481551
/* ALTER SYSTEM SET, RESET, RESET ALL */
15491552
else if (Matches2("ALTER", "SYSTEM"))
15501553
COMPLETE_WITH_LIST2("SET", "RESET");
@@ -2000,7 +2003,7 @@ psql_completion(const char *text, int start, int end)
20002003

20012004
/* CREATE FOREIGN DATA WRAPPER */
20022005
else if (Matches5("CREATE", "FOREIGN", "DATA", "WRAPPER", MatchAny))
2003-
COMPLETE_WITH_LIST2("HANDLER", "VALIDATOR");
2006+
COMPLETE_WITH_LIST3("HANDLER", "VALIDATOR", "OPTIONS");
20042007

20052008
/* CREATE INDEX --- is allowed inside CREATE SCHEMA, so use TailMatches */
20062009
/* First off we complete CREATE UNIQUE with "INDEX" */
@@ -2379,6 +2382,10 @@ psql_completion(const char *text, int start, int end)
23792382
else if (TailMatches3("FOREIGN", "DATA", "WRAPPER") &&
23802383
!TailMatches4("CREATE", MatchAny, MatchAny, MatchAny))
23812384
COMPLETE_WITH_QUERY(Query_for_list_of_fdws);
2385+
/* applies in CREATE SERVER */
2386+
else if (TailMatches4("FOREIGN", "DATA", "WRAPPER", MatchAny) &&
2387+
HeadMatches2("CREATE", "SERVER"))
2388+
COMPLETE_WITH_CONST("OPTIONS");
23822389

23832390
/* FOREIGN TABLE */
23842391
else if (TailMatches2("FOREIGN", "TABLE") &&
@@ -2823,6 +2830,8 @@ psql_completion(const char *text, int start, int end)
28232830
COMPLETE_WITH_QUERY(Query_for_list_of_user_mappings);
28242831
else if (Matches5("CREATE|ALTER|DROP", "USER", "MAPPING", "FOR", MatchAny))
28252832
COMPLETE_WITH_CONST("SERVER");
2833+
else if (Matches7("CREATE|ALTER", "USER", "MAPPING", "FOR", MatchAny, "SERVER", MatchAny))
2834+
COMPLETE_WITH_CONST("OPTIONS");
28262835

28272836
/*
28282837
* VACUUM [ FULL | FREEZE ] [ VERBOSE ] [ table ]

0 commit comments

Comments
 (0)