On Fri, Dec 21, 2018 at 02:51:51PM +0900, Tatsuro Yamada wrote: > Attached file is a WIP patch.
Before sorting out the exotic part of the feature, why not first fixing the simple cases where we know that tab completion is broken and can be improved? This is what I meant in this email: https://www.postgresql.org/message-id/20181219092255.gc...@paquier.xyz The attached patch implements the idea. What do you think? -- Michael
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 5ba6ffba8c..7b603508db 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -1566,9 +1566,20 @@ psql_completion(const char *text, int start, int end) COMPLETE_WITH("PARTITION"); else if (Matches("ALTER", "INDEX", MatchAny, "ATTACH", "PARTITION")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_indexes, NULL); - /* ALTER INDEX <name> ALTER COLUMN <colnum> */ - else if (Matches("ALTER", "INDEX", MatchAny, "ALTER", "COLUMN", MatchAny)) + /* ALTER INDEX <name> ALTER [COLUMN] <colnum> */ + else if (Matches("ALTER", "INDEX", MatchAny, "ALTER", MatchAny) || + Matches("ALTER", "INDEX", MatchAny, "ALTER", "COLUMN", MatchAny)) COMPLETE_WITH("SET STATISTICS"); + /* ALTER INDEX <name> ALTER [COLUMN] <colnum> SET */ + else if (Matches("ALTER", "INDEX", MatchAny, "ALTER", MatchAny, "SET") || + Matches("ALTER", "INDEX", MatchAny, "ALTER", "COLUMN", MatchAny, "SET")) + COMPLETE_WITH("STATISTICS"); + /* ALTER INDEX <name> ALTER [COLUMN] <colnum> SET STATISTICS */ + else if (Matches("ALTER", "INDEX", MatchAny, "ALTER", MatchAny, "SET", "STATISTICS") || + Matches("ALTER", "INDEX", MatchAny, "ALTER", "COLUMN", MatchAny, "SET", "STATISTICS")) + { + /* Enforce no completion here, as an integer has to be specified */ + } /* ALTER INDEX <name> SET */ else if (Matches("ALTER", "INDEX", MatchAny, "SET")) COMPLETE_WITH("(", "TABLESPACE"); @@ -1874,6 +1885,12 @@ psql_completion(const char *text, int start, int end) else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny, "SET", "STORAGE") || Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny, "SET", "STORAGE")) COMPLETE_WITH("PLAIN", "EXTERNAL", "EXTENDED", "MAIN"); + /* ALTER TABLE ALTER [COLUMN] <foo> SET STATISTICS */ + else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny, "SET", "STATISTICS") || + Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny, "SET", "STATISTICS")) + { + /* Enforce no completion here, as an integer has to be specified */ + } /* ALTER TABLE ALTER [COLUMN] <foo> DROP */ else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny, "DROP") || Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny, "DROP"))
signature.asc
Description: PGP signature