Improve tab-completion for TRUNCATE.

Author: Kota Miyake
Reviewed-by: Muhammad Usama
Discussion: https://postgr.es/m/f5d30053d00dcafda3280c9e267ecb0f@oss.nttdata.com
This commit is contained in:
Fujii Masao 2021-02-25 18:20:57 +09:00
parent a6f8dc47a0
commit 6b40d9bdbd
1 changed files with 13 additions and 0 deletions

View File

@ -3832,7 +3832,20 @@ psql_completion(const char *text, int start, int end)
/* TRUNCATE */
else if (Matches("TRUNCATE"))
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables,
" UNION SELECT 'TABLE'"
" UNION SELECT 'ONLY'");
else if (Matches("TRUNCATE", "TABLE"))
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables,
" UNION SELECT 'ONLY'");
else if (HeadMatches("TRUNCATE") && TailMatches("ONLY"))
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
else if (Matches("TRUNCATE", MatchAny) ||
Matches("TRUNCATE", "TABLE|ONLY", MatchAny) ||
Matches("TRUNCATE", "TABLE", "ONLY", MatchAny))
COMPLETE_WITH("RESTART IDENTITY", "CONTINUE IDENTITY", "CASCADE", "RESTRICT");
else if (HeadMatches("TRUNCATE") && TailMatches("IDENTITY"))
COMPLETE_WITH("CASCADE", "RESTRICT");
/* UNLISTEN */
else if (Matches("UNLISTEN"))