Skip to content

Commit 029722a

Browse files
committed
Improved tab completion for CLUSTER VERBOSE.
Jeff Janes
1 parent 68386fc commit 029722a

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

src/bin/psql/tab-complete.c

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,14 +1661,29 @@ psql_completion(char *text, int start, int end)
16611661
/* CLUSTER */
16621662

16631663
/*
1664-
* If the previous word is CLUSTER and not without produce list of tables
1664+
* If the previous word is CLUSTER and not WITHOUT produce list of tables
16651665
*/
16661666
else if (pg_strcasecmp(prev_wd, "CLUSTER") == 0 &&
16671667
pg_strcasecmp(prev2_wd, "WITHOUT") != 0)
1668+
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, "UNION SELECT 'VERBOSE'");
1669+
1670+
/*
1671+
* If the previous words are CLUSTER VERBOSE produce list of tables
1672+
*/
1673+
else if (pg_strcasecmp(prev_wd, "VERBOSE") == 0 &&
1674+
pg_strcasecmp(prev2_wd, "CLUSTER") == 0)
16681675
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
1676+
16691677
/* If we have CLUSTER <sth>, then add "USING" */
16701678
else if (pg_strcasecmp(prev2_wd, "CLUSTER") == 0 &&
1671-
pg_strcasecmp(prev_wd, "ON") != 0)
1679+
pg_strcasecmp(prev_wd, "ON") != 0 &&
1680+
pg_strcasecmp(prev_wd, "VERBOSE") != 0)
1681+
{
1682+
COMPLETE_WITH_CONST("USING");
1683+
}
1684+
/* If we have CLUSTER VERBOSE <sth>, then add "USING" */
1685+
else if (pg_strcasecmp(prev3_wd, "CLUSTER") == 0 &&
1686+
pg_strcasecmp(prev2_wd, "VERBOSE") == 0)
16721687
{
16731688
COMPLETE_WITH_CONST("USING");
16741689
}
@@ -1683,6 +1698,17 @@ psql_completion(char *text, int start, int end)
16831698
COMPLETE_WITH_QUERY(Query_for_index_of_table);
16841699
}
16851700

1701+
/*
1702+
* If we have CLUSTER VERBOSE <sth> USING, then add the index as well.
1703+
*/
1704+
else if (pg_strcasecmp(prev4_wd, "CLUSTER") == 0 &&
1705+
pg_strcasecmp(prev3_wd, "VERBOSE") == 0 &&
1706+
pg_strcasecmp(prev_wd, "USING") == 0)
1707+
{
1708+
completion_info_charp = prev2_wd;
1709+
COMPLETE_WITH_QUERY(Query_for_index_of_table);
1710+
}
1711+
16861712
/* COMMENT */
16871713
else if (pg_strcasecmp(prev_wd, "COMMENT") == 0)
16881714
COMPLETE_WITH_CONST("ON");

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