From: Michael Paquier Date: Mon, 15 Aug 2022 05:08:59 +0000 (+0900) Subject: Improve tab completion of ALTER TYPE in psql X-Git-Tag: REL_16_BETA1~1971 X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=f6c750d31d97a66a90e3389ae6832bf99cd15f30;p=postgresql.git Improve tab completion of ALTER TYPE in psql This commit adds support for more tab completion in this command as of "ALTER TYPE .. SET". The completion of "RENAME VALUE" was separated from the rest of the completions done for this command, so group everything together. Author: Vignesh C Discussion: https://postgr.es/m/CALDaNm1u83jtD2wysdw9XwokEacSXEyUpELajEvOMgJTc3pQ7g@mail.gmail.com --- diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index f265e043e95..62a39779b9d 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -2516,6 +2516,17 @@ psql_completion(const char *text, int start, int end) /* ALTER TYPE ALTER ATTRIBUTE */ else if (Matches("ALTER", "TYPE", MatchAny, "ALTER", "ATTRIBUTE", MatchAny)) COMPLETE_WITH("TYPE"); + /* complete ALTER TYPE RENAME VALUE with list of enum values */ + else if (Matches("ALTER", "TYPE", MatchAny, "RENAME", "VALUE")) + COMPLETE_WITH_ENUM_VALUE(prev3_wd); + /* ALTER TYPE SET */ + else if (Matches("ALTER", "TYPE", MatchAny, "SET")) + COMPLETE_WITH("(", "SCHEMA"); + /* complete ALTER TYPE SET ( with settable properties */ + else if (Matches("ALTER", "TYPE", MatchAny, "SET", "(")) + COMPLETE_WITH("ANALYZE", "RECEIVE", "SEND", "STORAGE", "SUBSCRIPT", + "TYPMOD_IN", "TYPMOD_OUT"); + /* complete ALTER GROUP */ else if (Matches("ALTER", "GROUP", MatchAny)) COMPLETE_WITH("ADD USER", "DROP USER", "RENAME TO"); @@ -2526,12 +2537,6 @@ psql_completion(const char *text, int start, int end) else if (Matches("ALTER", "GROUP", MatchAny, "ADD|DROP", "USER")) COMPLETE_WITH_QUERY(Query_for_list_of_roles); - /* - * If we have ALTER TYPE RENAME VALUE, provide list of enum values - */ - else if (Matches("ALTER", "TYPE", MatchAny, "RENAME", "VALUE")) - COMPLETE_WITH_ENUM_VALUE(prev3_wd); - /* * ANALYZE [ ( option [, ...] ) ] [ table_and_columns [, ...] ] * ANALYZE [ VERBOSE ] [ table_and_columns [, ...] ]