tab completion for "alter extension foobar update" yields a list of
tables. That is actively misleading. (This is not new in 9.6.)
It should complete to nothing, or "TO" followed by a list of available versions.
The attached patch takes approach 2. I thought of adding a ";" to the
list completions to signify you can optionally end the command
immediately after UPDATE and have it be a complete command. But I
thought perhaps that was too clever, and unprecedented.
Will add to commitfest-next
Cheers,
Jeff
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
new file mode 100644
index a62ffe6..85f7a1c
*** a/src/bin/psql/tab-complete.c
--- b/src/bin/psql/tab-complete.c
*************** static const SchemaQuery Query_for_list_
*** 820,825 ****
--- 820,832 ----
" 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 "\
*************** psql_completion(const char *text, int st
*** 1414,1419 ****
--- 1421,1440 ----
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");
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers