[PATCH] DROP tab completion
Hi hackers,
This time, I went through DROP tab completions
and noticed some tab completions missing for the following commands:
-DROP MATERIALIZED VIEW, DROP OWNED BY, DROP POLICY: missing
[CASCADE|RESTRICT] at the end
-DROP TRANSFORM: no completions after TRANSFORM
I made a patch for this.
Best wishes,
--
Ken Kato
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION
Attachments:
drop_tab_completion.patchtext/x-diff; charset=us-ascii; name=drop_tab_completion.patchDownload
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 630026da2f..2f412ca3db 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -3322,12 +3322,16 @@ psql_completion(const char *text, int start, int end)
COMPLETE_WITH("VIEW");
else if (Matches("DROP", "MATERIALIZED", "VIEW"))
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_matviews, NULL);
+ else if (Matches("DROP", "MATERIALIZED", "VIEW", MatchAny))
+ COMPLETE_WITH("CASCADE", "RESTRICT");
/* DROP OWNED BY */
else if (Matches("DROP", "OWNED"))
COMPLETE_WITH("BY");
else if (Matches("DROP", "OWNED", "BY"))
COMPLETE_WITH_QUERY(Query_for_list_of_roles);
+ else if (Matches("DROP", "OWNED", "BY", MatchAny))
+ COMPLETE_WITH("CASCADE", "RESTRICT");
/* DROP TEXT SEARCH */
else if (Matches("DROP", "TEXT", "SEARCH"))
@@ -3368,6 +3372,8 @@ psql_completion(const char *text, int start, int end)
completion_info_charp = prev2_wd;
COMPLETE_WITH_QUERY(Query_for_list_of_tables_for_policy);
}
+ else if (Matches("DROP", "POLICY", MatchAny, "ON", MatchAny))
+ COMPLETE_WITH("CASCADE", "RESTRICT");
/* DROP RULE */
else if (Matches("DROP", "RULE", MatchAny))
@@ -3380,6 +3386,21 @@ psql_completion(const char *text, int start, int end)
else if (Matches("DROP", "RULE", MatchAny, "ON", MatchAny))
COMPLETE_WITH("CASCADE", "RESTRICT");
+ /* DROP TRANSFORM */
+ else if (Matches("DROP", "TRANSFORM"))
+ COMPLETE_WITH("FOR");
+ else if (Matches("DROP", "TRANSFORM", "FOR"))
+ COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_datatypes, NULL);
+ else if (Matches("DROP", "TRANSFORM", "FOR", MatchAny))
+ COMPLETE_WITH("LANGUAGE");
+ else if (Matches("DROP", "TRANSFORM", "FOR", MatchAny, "LANGUAGE"))
+ {
+ completion_info_charp = prev2_wd;
+ COMPLETE_WITH_QUERY(Query_for_list_of_languages);
+ }
+ else if (Matches("DROP", "TRANSFORM", "FOR", MatchAny, "LANGUAGE", MatchAny))
+ COMPLETE_WITH("CASCADE", "RESTRICT");
+
/* EXECUTE */
else if (Matches("EXECUTE"))
COMPLETE_WITH_QUERY(Query_for_list_of_prepared_statements);
The following review has been posted through the commitfest application:
make installcheck-world: tested, passed
Implements feature: tested, passed
Spec compliant: tested, passed
Documentation: not tested
The patch applies cleanly and the functionality seems to work well. (master e7122548a3)
The new status of this patch is: Ready for Committer
On Tue, Nov 30, 2021 at 03:17:07PM +0000, Asif Rehman wrote:
The patch applies cleanly and the functionality seems to work well. (master e7122548a3)
The new status of this patch is: Ready for Committer
+ else if (Matches("DROP", "MATERIALIZED", "VIEW", MatchAny))
+ COMPLETE_WITH("CASCADE", "RESTRICT");
[...]
+ else if (Matches("DROP", "OWNED", "BY", MatchAny))
+ COMPLETE_WITH("CASCADE", "RESTRICT");
This stuff is gathered around line 3284 in tab-complete.c as of HEAD
at 538724f, but I think that you have done things right as there are
already sections for those commands and they have multiple keywords.
So, applied. Thanks!
--
Michael