Skip to content

Commit 4189e3d

Browse files
committed
psql: Add completion support for DROP INDEX CONCURRENTLY
based on patch by Kyotaro Horiguchi
1 parent cf7dfbf commit 4189e3d

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/bin/psql/tab-complete.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2009,8 +2009,8 @@ psql_completion(const char *text, int start, int end)
20092009
else if (TailMatches3("INDEX|CONCURRENTLY", MatchAny, "ON") ||
20102010
TailMatches2("INDEX|CONCURRENTLY", "ON"))
20112011
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tm, NULL);
2012-
/* Complete ... INDEX CONCURRENTLY with "ON" and existing indexes */
2013-
else if (TailMatches2("INDEX", "CONCURRENTLY"))
2012+
/* Complete CREATE|UNIQUE INDEX CONCURRENTLY with "ON" and existing indexes */
2013+
else if (TailMatches3("CREATE|UNIQUE", "INDEX", "CONCURRENTLY"))
20142014
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_indexes,
20152015
" UNION SELECT 'ON'");
20162016
/* Complete CREATE|UNIQUE INDEX [CONCURRENTLY] <sth> with "ON" */
@@ -2247,7 +2247,7 @@ psql_completion(const char *text, int start, int end)
22472247
/* DROP */
22482248
/* Complete DROP object with CASCADE / RESTRICT */
22492249
else if (Matches3("DROP",
2250-
"COLLATION|CONVERSION|DOMAIN|EXTENSION|INDEX|LANGUAGE|SCHEMA|SEQUENCE|SERVER|TABLE|TYPE|VIEW",
2250+
"COLLATION|CONVERSION|DOMAIN|EXTENSION|LANGUAGE|SCHEMA|SEQUENCE|SERVER|TABLE|TYPE|VIEW",
22512251
MatchAny) ||
22522252
(Matches4("DROP", "AGGREGATE|FUNCTION", MatchAny, MatchAny) &&
22532253
ends_with(prev_wd, ')')) ||
@@ -2265,6 +2265,17 @@ psql_completion(const char *text, int start, int end)
22652265
else if (Matches2("DROP", "FOREIGN"))
22662266
COMPLETE_WITH_LIST2("DATA WRAPPER", "TABLE");
22672267

2268+
/* DROP INDEX */
2269+
else if (Matches2("DROP", "INDEX"))
2270+
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_indexes,
2271+
" UNION SELECT 'CONCURRENTLY'");
2272+
else if (Matches3("DROP", "INDEX", "CONCURRENTLY"))
2273+
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_indexes, NULL);
2274+
else if (Matches3("DROP", "INDEX", MatchAny))
2275+
COMPLETE_WITH_LIST2("CASCADE", "RESTRICT");
2276+
else if (Matches4("DROP", "INDEX", "CONCURRENTLY", MatchAny))
2277+
COMPLETE_WITH_LIST2("CASCADE", "RESTRICT");
2278+
22682279
/* DROP MATERIALIZED VIEW */
22692280
else if (Matches2("DROP", "MATERIALIZED"))
22702281
COMPLETE_WITH_CONST("VIEW");

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