Hi hackers, Please find attached a patch that adds the following tab completions for CREATE TABLE:
- ( or PARTITION OF after the name - options after the column list - ON COMMIT actions for temp tables Regards, ilmari -- "The surreality of the universe tends towards a maximum" -- Skud's Law "Never formulate a law or axiom that you're not prepared to live with the consequences of." -- Skud's Meta-Law
>From ed15e53b370d8ee4320961f17ed66cbf60621d28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= <ilm...@ilmari.org> Date: Fri, 23 Nov 2018 15:23:21 +0000 Subject: [PATCH] Tab complete more options for CREATE TABLE - ( or PARTITION OF after the name - options after the column list - ON COMMIT actions for temp tables --- src/bin/psql/tab-complete.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 90cc1fe215..61b89c9370 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -2412,6 +2412,19 @@ psql_completion(const char *text, int start, int end) /* Limited completion support for partition bound specification */ else if (TailMatches("PARTITION", "OF", MatchAny)) COMPLETE_WITH("FOR VALUES", "DEFAULT"); + /* Complete after CREATE TABLE <name> */ + else if (TailMatches("CREATE", "TABLE", MatchAny) || + TailMatches("CREATE", "TEMP|TEMPORARY|UNLOGGED", "TABLE", MatchAny)) + COMPLETE_WITH("(", "PARTITION OF"); + /* Complete options after CREATE TABLE name (...) */ + else if (TailMatches("CREATE", "TABLE", MatchAny, "(*)") || + TailMatches("CREATE", "UNLOGGED", "TABLE", MatchAny, "(*)")) + COMPLETE_WITH("INHERITS (", "PARTITION BY", "WITH (", "TABLESPACE"); + else if (TailMatches("CREATE", "TEMP|TEMPORARY", "TABLE", MatchAny, "(*)")) + COMPLETE_WITH("INHERITS (", "PARTITION BY", "WITH (", "ON COMMIT", "TABLESPACE"); + /* Complete ON COMMIT actions for temp tables */ + else if (TailMatches("ON", "COMMIT")) + COMPLETE_WITH("PRESERVE ROWS", "DELETE ROWS", "DROP"); /* CREATE TABLESPACE */ else if (Matches("CREATE", "TABLESPACE", MatchAny)) -- 2.19.2