summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFujii Masao2021-02-25 09:20:57 +0000
committerFujii Masao2021-02-25 09:20:57 +0000
commit6b40d9bdbdc9f873868b0ddecacd9a307fc8ee26 (patch)
treeb1291968bbdbca92160fa6a187c62bb5e1ca8ec2
parenta6f8dc47a0582e37c234c8e916377b46d2b03817 (diff)
Improve tab-completion for TRUNCATE.
Author: Kota Miyake Reviewed-by: Muhammad Usama Discussion: https://postgr.es/m/f5d30053d00dcafda3280c9e267ecb0f@oss.nttdata.com
-rw-r--r--src/bin/psql/tab-complete.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index d777992559..9f0208ac49 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -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"))