diff options
author | Michael Paquier <michael@paquier.xyz> | 2018-12-25 14:20:46 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2018-12-25 14:20:46 +0900 |
commit | f89ae34ab8b4d9e9ce8af6bd889238b0ccff17cb (patch) | |
tree | f48157fbcc60fcb7c3c1e4bebe30a26d99dc6fc7 /src | |
parent | b981df4cc09aca978c5ce55e437a74913d09cccc (diff) | |
download | postgresql-f89ae34ab8b4d9e9ce8af6bd889238b0ccff17cb.tar.gz postgresql-f89ae34ab8b4d9e9ce8af6bd889238b0ccff17cb.zip |
Improve tab completion of ALTER INDEX/TABLE with SET STATISTICS in psql
This fixes two issues with the completion of ALTER TABLE and ALTER INDEX
after SET STATISTICS is typed, trying to suggest schema objects while
the grammar only allows integers.
The tab completion of ALTER INDEX is made smarter by handling properly
more patterns. COLUMN is an optional keyword, but as no column numbers
can be suggested yet as possible input simply adjust the completion so
as no incorrect queries are generated.
Author: Michael Paquier
Reviewed-by: Tatsuro Yamada
Discussion: https://postgr.es/m/20181219092255.GC680@paquier.xyz
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/psql/tab-complete.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index c504a9fd1c7..91df96e796f 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -1601,9 +1601,20 @@ psql_completion(const char *text, int start, int end) COMPLETE_WITH("PARTITION"); else if (Matches("ALTER", "INDEX", MatchAny, "ATTACH", "PARTITION")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_indexes, NULL); + /* ALTER INDEX <name> ALTER */ + else if (Matches("ALTER", "INDEX", MatchAny, "ALTER")) + COMPLETE_WITH("COLUMN"); /* ALTER INDEX <name> ALTER COLUMN <colnum> */ else if (Matches("ALTER", "INDEX", MatchAny, "ALTER", "COLUMN", MatchAny)) COMPLETE_WITH("SET STATISTICS"); + /* ALTER INDEX <name> ALTER COLUMN <colnum> SET */ + else if (Matches("ALTER", "INDEX", MatchAny, "ALTER", "COLUMN", MatchAny, "SET")) + COMPLETE_WITH("STATISTICS"); + /* ALTER INDEX <name> ALTER COLUMN <colnum> SET STATISTICS */ + else if (Matches("ALTER", "INDEX", MatchAny, "ALTER", "COLUMN", MatchAny, "SET", "STATISTICS")) + { + /* Enforce no completion here, as an integer has to be specified */ + } /* ALTER INDEX <name> SET */ else if (Matches("ALTER", "INDEX", MatchAny, "SET")) COMPLETE_WITH("(", "TABLESPACE"); @@ -1909,6 +1920,12 @@ psql_completion(const char *text, int start, int end) else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny, "SET", "STORAGE") || Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny, "SET", "STORAGE")) COMPLETE_WITH("PLAIN", "EXTERNAL", "EXTENDED", "MAIN"); + /* ALTER TABLE ALTER [COLUMN] <foo> SET STATISTICS */ + else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny, "SET", "STATISTICS") || + Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny, "SET", "STATISTICS")) + { + /* Enforce no completion here, as an integer has to be specified */ + } /* ALTER TABLE ALTER [COLUMN] <foo> DROP */ else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny, "DROP") || Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny, "DROP")) |