Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 6b40d9b

Browse files
committed
Improve tab-completion for TRUNCATE.
Author: Kota Miyake Reviewed-by: Muhammad Usama Discussion: https://postgr.es/m/f5d30053d00dcafda3280c9e267ecb0f@oss.nttdata.com
1 parent a6f8dc4 commit 6b40d9b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/bin/psql/tab-complete.c

+13
Original file line numberDiff line numberDiff line change
@@ -3832,7 +3832,20 @@ psql_completion(const char *text, int start, int end)
38323832

38333833
/* TRUNCATE */
38343834
else if (Matches("TRUNCATE"))
3835+
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables,
3836+
" UNION SELECT 'TABLE'"
3837+
" UNION SELECT 'ONLY'");
3838+
else if (Matches("TRUNCATE", "TABLE"))
3839+
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables,
3840+
" UNION SELECT 'ONLY'");
3841+
else if (HeadMatches("TRUNCATE") && TailMatches("ONLY"))
38353842
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
3843+
else if (Matches("TRUNCATE", MatchAny) ||
3844+
Matches("TRUNCATE", "TABLE|ONLY", MatchAny) ||
3845+
Matches("TRUNCATE", "TABLE", "ONLY", MatchAny))
3846+
COMPLETE_WITH("RESTART IDENTITY", "CONTINUE IDENTITY", "CASCADE", "RESTRICT");
3847+
else if (HeadMatches("TRUNCATE") && TailMatches("IDENTITY"))
3848+
COMPLETE_WITH("CASCADE", "RESTRICT");
38363849

38373850
/* UNLISTEN */
38383851
else if (Matches("UNLISTEN"))

0 commit comments

Comments
 (0)