mirror of
https://github.com/postgres/postgres.git
synced 2025-05-20 00:03:14 -04:00
Improve tab completion of ALTER INDEX/TABLE with SET STATISTICS in psql
This fixes two issues with the completion of ALTER TABLE and ALTER INDEX after SET STATISTICS is typed, trying to suggest schema objects while the grammar only allows integers. The tab completion of ALTER INDEX is made smarter by handling properly more patterns. COLUMN is an optional keyword, but as no column numbers can be suggested yet as possible input simply adjust the completion so as no incorrect queries are generated. Author: Michael Paquier Reviewed-by: Tatsuro Yamada Discussion: https://postgr.es/m/20181219092255.GC680@paquier.xyz
This commit is contained in:
parent
b981df4cc0
commit
f89ae34ab8
@ -1601,9 +1601,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 */
|
||||
else if (Matches("ALTER", "INDEX", MatchAny, "ALTER"))
|
||||
COMPLETE_WITH("COLUMN");
|
||||
/* ALTER INDEX <name> ALTER COLUMN <colnum> */
|
||||
else if (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", "COLUMN", MatchAny, "SET"))
|
||||
COMPLETE_WITH("STATISTICS");
|
||||
/* ALTER INDEX <name> ALTER COLUMN <colnum> SET STATISTICS */
|
||||
else if (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");
|
||||
@ -1909,6 +1920,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", "COLUMN", MatchAny, "SET", "STATISTICS") ||
|
||||
Matches("ALTER", "TABLE", MatchAny, "ALTER", 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"))
|
||||
|
Loading…
x
Reference in New Issue
Block a user