[PATCH] Improve tab completion for CREATE TABLE

Поиск
Список
Период
Сортировка
От ilmari@ilmari.org (Dagfinn Ilmari Mannsåker)
Тема [PATCH] Improve tab completion for CREATE TABLE
Дата
Msg-id d8j1s77kdbb.fsf@dalvik.ping.uio.no
обсуждение исходный текст
Ответы Re: [PATCH] Improve tab completion for CREATE TABLE  (ilmari@ilmari.org (Dagfinn Ilmari Mannsåker))
Список pgsql-hackers
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?= <ilmari@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


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Stephen Frost
Дата:
Сообщение: Re: Updated backup APIs for non-exclusive backups
Следующее
От: Sergei Kornilov
Дата:
Сообщение: Re: pgsql: Integrate recovery.conf into postgresql.conf