Skip to content

Commit b1bfb28

Browse files
committed
psql: Improve CREATE INDEX CONCURRENTLY tab completion
The completion of CREATE INDEX CONCURRENTLY was lacking in several ways compared to a plain CREATE INDEX command: - CREATE INDEX <name> ON completes table names, but didn't with CONCURRENTLY. - CREATE INDEX completes ON and existing index names, but with CONCURRENTLY it only completed ON. - CREATE INDEX <name> completes ON, but didn't with CONCURRENTLY. These are now all fixed.
1 parent bc56d58 commit b1bfb28

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/bin/psql/tab-complete.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2005,15 +2005,17 @@ psql_completion(const char *text, int start, int end)
20052005
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_indexes,
20062006
" UNION SELECT 'ON'"
20072007
" UNION SELECT 'CONCURRENTLY'");
2008-
/* Complete ... INDEX [<name>] ON with a list of tables */
2009-
else if (TailMatches3("INDEX", MatchAny, "ON") ||
2008+
/* Complete ... INDEX|CONCURRENTLY [<name>] ON with a list of tables */
2009+
else if (TailMatches3("INDEX|CONCURRENTLY", MatchAny, "ON") ||
20102010
TailMatches2("INDEX|CONCURRENTLY", "ON"))
20112011
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tm, NULL);
2012-
/* If we have CREATE|UNIQUE INDEX CONCURRENTLY, then add "ON" */
2012+
/* Complete ... INDEX CONCURRENTLY with "ON" and existing indexes */
20132013
else if (TailMatches2("INDEX", "CONCURRENTLY"))
2014-
COMPLETE_WITH_CONST("ON");
2015-
/* If we have CREATE|UNIQUE INDEX <sth>, then add "ON" */
2016-
else if (TailMatches3("CREATE|UNIQUE", "INDEX", MatchAny))
2014+
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_indexes,
2015+
" UNION SELECT 'ON'");
2016+
/* Complete CREATE|UNIQUE INDEX [CONCURRENTLY] <sth> with "ON" */
2017+
else if (TailMatches3("CREATE|UNIQUE", "INDEX", MatchAny) ||
2018+
TailMatches4("CREATE|UNIQUE", "INDEX", "CONCURRENTLY", MatchAny))
20172019
COMPLETE_WITH_CONST("ON");
20182020

20192021
/*

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