aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bin/psql/tab-complete.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 8469d9ff03d..d31fd25b8d8 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -820,6 +820,13 @@ static const SchemaQuery Query_for_list_of_matviews = {
" WHERE (%d = pg_catalog.length('%s'))"\
" AND pg_catalog.quote_ident(name)='%s'"
+/* the silly-looking length condition is just to eat up the current word */
+#define Query_for_list_of_available_extension_versions_with_TO \
+" SELECT 'TO ' || pg_catalog.quote_ident(version) "\
+" FROM pg_catalog.pg_available_extension_versions "\
+" WHERE (%d = pg_catalog.length('%s'))"\
+" AND pg_catalog.quote_ident(name)='%s'"
+
#define Query_for_list_of_prepared_statements \
" SELECT pg_catalog.quote_ident(name) "\
" FROM pg_catalog.pg_prepared_statements "\
@@ -1414,6 +1421,20 @@ psql_completion(const char *text, int start, int end)
else if (Matches3("ALTER", "EXTENSION", MatchAny))
COMPLETE_WITH_LIST4("ADD", "DROP", "UPDATE", "SET SCHEMA");
+ /* ALTER EXTENSION <name> UPDATE */
+ else if (Matches4("ALTER", "EXTENSION", MatchAny, "UPDATE"))
+ {
+ completion_info_charp = prev2_wd;
+ COMPLETE_WITH_QUERY(Query_for_list_of_available_extension_versions_with_TO);
+ }
+
+ /* ALTER EXTENSION <name> UPDATE TO */
+ else if (Matches5("ALTER", "EXTENSION", MatchAny, "UPDATE", "TO"))
+ {
+ completion_info_charp = prev3_wd;
+ COMPLETE_WITH_QUERY(Query_for_list_of_available_extension_versions);
+ }
+
/* ALTER FOREIGN */
else if (Matches2("ALTER", "FOREIGN"))
COMPLETE_WITH_LIST2("DATA WRAPPER", "TABLE");