Skip to content

Commit f44ceb4

Browse files
committed
Improve psql tab completion for views, FDWs, sequences and transforms
The following improvements are done: - Addition of type completion for ALTER SEQUENCE AS. - Ignore ALTER for transforms, as the command is not supported. - Addition of more completion for ALTER FOREIGN DATA WRAPPER. - Addition of options related to columns in ALTER VIEW. This is a continuation of the work done in 0cd6d3b. Author: Ken Kato Discussion: https://postgr.es/m/9497ae9ca1b31eb9b1e97aded1c2ab07@oss.nttdata.com
1 parent 276db87 commit f44ceb4

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/bin/psql/tab-complete.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,7 +1088,7 @@ static const pgsql_thing_t words_after_create[] = {
10881088
{"TEMPORARY", NULL, NULL, NULL, THING_NO_DROP | THING_NO_ALTER}, /* for CREATE TEMPORARY
10891089
* TABLE ... */
10901090
{"TEXT SEARCH", NULL, NULL, NULL},
1091-
{"TRANSFORM", NULL, NULL, NULL},
1091+
{"TRANSFORM", NULL, NULL, NULL, THING_NO_ALTER},
10921092
{"TRIGGER", "SELECT pg_catalog.quote_ident(tgname) FROM pg_catalog.pg_trigger WHERE substring(pg_catalog.quote_ident(tgname),1,%d)='%s' AND NOT tgisinternal"},
10931093
{"TYPE", NULL, NULL, &Query_for_list_of_datatypes},
10941094
{"UNIQUE", NULL, NULL, NULL, THING_NO_DROP | THING_NO_ALTER}, /* for CREATE UNIQUE
@@ -1754,7 +1754,10 @@ psql_completion(const char *text, int start, int end)
17541754

17551755
/* ALTER FOREIGN DATA WRAPPER <name> */
17561756
else if (Matches("ALTER", "FOREIGN", "DATA", "WRAPPER", MatchAny))
1757-
COMPLETE_WITH("HANDLER", "VALIDATOR", "OPTIONS", "OWNER TO", "RENAME TO");
1757+
COMPLETE_WITH("HANDLER", "VALIDATOR", "NO",
1758+
"OPTIONS", "OWNER TO", "RENAME TO");
1759+
else if (Matches("ALTER", "FOREIGN", "DATA", "WRAPPER", MatchAny, "NO"))
1760+
COMPLETE_WITH("HANDLER", "VALIDATOR");
17581761

17591762
/* ALTER FOREIGN TABLE <name> */
17601763
else if (Matches("ALTER", "FOREIGN", "TABLE", MatchAny))
@@ -1907,9 +1910,12 @@ psql_completion(const char *text, int start, int end)
19071910
COMPLETE_WITH("DEFAULT", "NOT NULL", "SCHEMA");
19081911
/* ALTER SEQUENCE <name> */
19091912
else if (Matches("ALTER", "SEQUENCE", MatchAny))
1910-
COMPLETE_WITH("INCREMENT", "MINVALUE", "MAXVALUE", "RESTART", "NO",
1911-
"CACHE", "CYCLE", "SET SCHEMA", "OWNED BY", "OWNER TO",
1912-
"RENAME TO");
1913+
COMPLETE_WITH("AS", "INCREMENT", "MINVALUE", "MAXVALUE", "RESTART",
1914+
"NO", "CACHE", "CYCLE", "SET SCHEMA", "OWNED BY",
1915+
"OWNER TO", "RENAME TO");
1916+
/* ALTER SEQUENCE <name> AS */
1917+
else if (TailMatches("ALTER", "SEQUENCE", MatchAny, "AS"))
1918+
COMPLETE_WITH_CS("smallint", "integer", "bigint");
19131919
/* ALTER SEQUENCE <name> NO */
19141920
else if (Matches("ALTER", "SEQUENCE", MatchAny, "NO"))
19151921
COMPLETE_WITH("MINVALUE", "MAXVALUE", "CYCLE");
@@ -1935,6 +1941,10 @@ psql_completion(const char *text, int start, int end)
19351941
COMPLETE_WITH_ATTR(prev2_wd, " UNION SELECT 'COLUMN' UNION SELECT 'TO'");
19361942
else if (Matches("ALTER", "VIEW", MatchAny, "ALTER|RENAME", "COLUMN"))
19371943
COMPLETE_WITH_ATTR(prev3_wd, "");
1944+
/* ALTER VIEW xxx ALTER [ COLUMN ] yyy */
1945+
else if (Matches("ALTER", "VIEW", MatchAny, "ALTER", MatchAny) ||
1946+
Matches("ALTER", "VIEW", MatchAny, "ALTER", "COLUMN", MatchAny))
1947+
COMPLETE_WITH("SET DEFAULT", "DROP DEFAULT");
19381948
/* ALTER VIEW xxx RENAME yyy */
19391949
else if (Matches("ALTER", "VIEW", MatchAny, "RENAME", MatchAnyExcept("TO")))
19401950
COMPLETE_WITH("TO");

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy