pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: ilmari@ilmari.org
To: pgsql-hackers@postgresql.org
Subject: [PATCH] Improve tab completion for CREATE TABLE
Date: Mon, 26 Nov 2018 16:34:32 +0000
Message-ID: <d8j1s77kdbb.fsf@dalvik.ping.uio.no> (raw)

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

Attachments:

0001-Tab-complete-more-options-for-CREATE-TABLE.patch (text/x-diff, 1.7K) download 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

view thread (15+ messages)  latest in thread

Message-ID: <d8j1s77kdbb.fsf@dalvik.ping.uio.no>
Permalink:  ../d8j1s77kdbb.fsf@dalvik.ping.uio.no/
Also on:    postgresql.org/message-id/d8j1s77kdbb.fsf@dalvik.ping.uio.no

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: ilmari@ilmari.org
  Subject: Re: [PATCH] Improve tab completion for CREATE TABLE
  In-Reply-To: <d8j1s77kdbb.fsf@dalvik.ping.uio.no>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox