git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1784f27)
Improve tab completion of REINDEX in psql
2020年8月11日 05:37:38 +0000 (14:37 +0900)
2020年8月11日 05:37:38 +0000 (14:37 +0900)
This allows the tab completion of REINDEX to handle an optional
parenthesized list of options. This case is more complicated than
VACUUM or ANALYZE because of CONCURRENTLY and the different object types
to consider with the reindex.

Author: Justin Pryzby
Reviewed-by: Alexey Kondratov, Michael Paquier
Discussion: https://postgr.es/m/20200403182712.GR14618@telsasoft.com


diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index c4af40bfa9fa7ebbb5f824433c7fce21558f1d04..f41785f11c12e68d4f63facd1699e1ccf898e586 100644 (file)
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -3430,28 +3430,48 @@ psql_completion(const char *text, int start, int end)
COMPLETE_WITH("DATA");
/* REINDEX */
- else if (Matches("REINDEX"))
+ else if (Matches("REINDEX") ||
+ Matches("REINDEX", "(*)"))
COMPLETE_WITH("TABLE", "INDEX", "SYSTEM", "SCHEMA", "DATABASE");
- else if (Matches("REINDEX", "TABLE"))
+ else if (Matches("REINDEX", "TABLE") ||
+ Matches("REINDEX", "(*)", "TABLE"))
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_indexables,
" UNION SELECT 'CONCURRENTLY'");
- else if (Matches("REINDEX", "INDEX"))
+ else if (Matches("REINDEX", "INDEX") ||
+ Matches("REINDEX", "(*)", "INDEX"))
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_indexes,
" UNION SELECT 'CONCURRENTLY'");
- else if (Matches("REINDEX", "SCHEMA"))
+ else if (Matches("REINDEX", "SCHEMA") ||
+ Matches("REINDEX", "(*)", "SCHEMA"))
COMPLETE_WITH_QUERY(Query_for_list_of_schemas
" UNION SELECT 'CONCURRENTLY'");
- else if (Matches("REINDEX", "SYSTEM|DATABASE"))
+ else if (Matches("REINDEX", "SYSTEM|DATABASE") ||
+ Matches("REINDEX", "(*)", "SYSTEM|DATABASE"))
COMPLETE_WITH_QUERY(Query_for_list_of_databases
" UNION SELECT 'CONCURRENTLY'");
- else if (Matches("REINDEX", "TABLE", "CONCURRENTLY"))
+ else if (Matches("REINDEX", "TABLE", "CONCURRENTLY") ||
+ Matches("REINDEX", "(*)", "TABLE", "CONCURRENTLY"))
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_indexables, NULL);
- else if (Matches("REINDEX", "INDEX", "CONCURRENTLY"))
+ else if (Matches("REINDEX", "INDEX", "CONCURRENTLY") ||
+ Matches("REINDEX", "(*)", "INDEX", "CONCURRENTLY"))
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_indexes, NULL);
- else if (Matches("REINDEX", "SCHEMA", "CONCURRENTLY"))
+ else if (Matches("REINDEX", "SCHEMA", "CONCURRENTLY") ||
+ Matches("REINDEX", "(*)", "SCHEMA", "CONCURRENTLY"))
COMPLETE_WITH_QUERY(Query_for_list_of_schemas);
- else if (Matches("REINDEX", "SYSTEM|DATABASE", "CONCURRENTLY"))
+ else if (Matches("REINDEX", "SYSTEM|DATABASE", "CONCURRENTLY") ||
+ Matches("REINDEX", "(*)", "SYSTEM|DATABASE", "CONCURRENTLY"))
COMPLETE_WITH_QUERY(Query_for_list_of_databases);
+ else if (HeadMatches("REINDEX", "(*") &&
+ !HeadMatches("REINDEX", "(*)"))
+ {
+ /*
+ * This fires if we're in an unfinished parenthesized option list.
+ * get_previous_words treats a completed parenthesized option list as
+ * one word, so the above test is correct.
+ */
+ if (ends_with(prev_wd, '(') || ends_with(prev_wd, ','))
+ COMPLETE_WITH("VERBOSE");
+ }
/* SECURITY LABEL */
else if (Matches("SECURITY"))
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /