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

Commit 9270778

Browse files
committed
Improve psql tab completion for various DROP commands
The following improvements are done: - Handling of RESTRICT/CASCADE for DROP OWNED, matviews and policies. - Handling of DROP TRANSFORM This is a continuation of the work done in 0cd6d3b and f44ceb4. Author: Ken Kato Reviewed-by: Asif Rehman Discussion: https://postgr.es/m/0fafb73f3a0c6bcec817a25ca9d5a853@oss.nttdata.com
1 parent 538724f commit 9270778

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/bin/psql/tab-complete.c

+21
Original file line numberDiff line numberDiff line change
@@ -3322,12 +3322,16 @@ psql_completion(const char *text, int start, int end)
33223322
COMPLETE_WITH("VIEW");
33233323
else if (Matches("DROP", "MATERIALIZED", "VIEW"))
33243324
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_matviews, NULL);
3325+
else if (Matches("DROP", "MATERIALIZED", "VIEW", MatchAny))
3326+
COMPLETE_WITH("CASCADE", "RESTRICT");
33253327

33263328
/* DROP OWNED BY */
33273329
else if (Matches("DROP", "OWNED"))
33283330
COMPLETE_WITH("BY");
33293331
else if (Matches("DROP", "OWNED", "BY"))
33303332
COMPLETE_WITH_QUERY(Query_for_list_of_roles);
3333+
else if (Matches("DROP", "OWNED", "BY", MatchAny))
3334+
COMPLETE_WITH("CASCADE", "RESTRICT");
33313335

33323336
/* DROP TEXT SEARCH */
33333337
else if (Matches("DROP", "TEXT", "SEARCH"))
@@ -3368,6 +3372,8 @@ psql_completion(const char *text, int start, int end)
33683372
completion_info_charp = prev2_wd;
33693373
COMPLETE_WITH_QUERY(Query_for_list_of_tables_for_policy);
33703374
}
3375+
else if (Matches("DROP", "POLICY", MatchAny, "ON", MatchAny))
3376+
COMPLETE_WITH("CASCADE", "RESTRICT");
33713377

33723378
/* DROP RULE */
33733379
else if (Matches("DROP", "RULE", MatchAny))
@@ -3380,6 +3386,21 @@ psql_completion(const char *text, int start, int end)
33803386
else if (Matches("DROP", "RULE", MatchAny, "ON", MatchAny))
33813387
COMPLETE_WITH("CASCADE", "RESTRICT");
33823388

3389+
/* DROP TRANSFORM */
3390+
else if (Matches("DROP", "TRANSFORM"))
3391+
COMPLETE_WITH("FOR");
3392+
else if (Matches("DROP", "TRANSFORM", "FOR"))
3393+
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_datatypes, NULL);
3394+
else if (Matches("DROP", "TRANSFORM", "FOR", MatchAny))
3395+
COMPLETE_WITH("LANGUAGE");
3396+
else if (Matches("DROP", "TRANSFORM", "FOR", MatchAny, "LANGUAGE"))
3397+
{
3398+
completion_info_charp = prev2_wd;
3399+
COMPLETE_WITH_QUERY(Query_for_list_of_languages);
3400+
}
3401+
else if (Matches("DROP", "TRANSFORM", "FOR", MatchAny, "LANGUAGE", MatchAny))
3402+
COMPLETE_WITH("CASCADE", "RESTRICT");
3403+
33833404
/* EXECUTE */
33843405
else if (Matches("EXECUTE"))
33853406
COMPLETE_WITH_QUERY(Query_for_list_of_prepared_statements);

0 commit comments

Comments
 (0)