truncate_tab_completion.patch
text/x-diff
Filename: truncate_tab_completion.patch
Type: text/x-diff
Part: 0
Patch
Format: unified
| File | + | − |
|---|---|---|
| src/bin/psql/tab-complete.c | 13 | 0 |
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 1e1c315bae..ef9ef4cb25 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -3799,7 +3799,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"))