Skip to content

Commit 7c0b49c

Browse files
committed
Tab complete CREATE EXTENSION .. VERSION.
Jeff Janes
1 parent 84ef9c5 commit 7c0b49c

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/bin/psql/tab-complete.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,13 @@ static const SchemaQuery Query_for_list_of_matviews = {
729729
" FROM pg_catalog.pg_available_extensions "\
730730
" WHERE substring(pg_catalog.quote_ident(name),1,%d)='%s' AND installed_version IS NULL"
731731

732+
/* the silly-looking length condition is just to eat up the current word */
733+
#define Query_for_list_of_available_extension_versions \
734+
" SELECT pg_catalog.quote_ident(version) "\
735+
" FROM pg_catalog.pg_available_extension_versions "\
736+
" WHERE (%d = pg_catalog.length('%s'))"\
737+
" AND pg_catalog.quote_ident(name)='%s'"
738+
732739
#define Query_for_list_of_prepared_statements \
733740
" SELECT pg_catalog.quote_ident(name) "\
734741
" FROM pg_catalog.pg_prepared_statements "\
@@ -2266,10 +2273,18 @@ psql_completion(const char *text, int start, int end)
22662273
pg_strcasecmp(prev2_wd, "EXTENSION") == 0)
22672274
{
22682275
static const char *const list_CREATE_EXTENSION[] =
2269-
{"WITH SCHEMA", "CASCADE", NULL};
2276+
{"WITH SCHEMA", "CASCADE", "VERSION", NULL};
22702277

22712278
COMPLETE_WITH_LIST(list_CREATE_EXTENSION);
22722279
}
2280+
/* CREATE EXTENSION <name> VERSION */
2281+
else if (pg_strcasecmp(prev4_wd, "CREATE") == 0 &&
2282+
pg_strcasecmp(prev3_wd, "EXTENSION") == 0 &&
2283+
pg_strcasecmp(prev_wd, "VERSION") == 0)
2284+
{
2285+
completion_info_charp = prev2_wd;
2286+
COMPLETE_WITH_QUERY(Query_for_list_of_available_extension_versions);
2287+
}
22732288

22742289
/* CREATE FOREIGN */
22752290
else if (pg_strcasecmp(prev2_wd, "CREATE") == 0 &&

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