Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gRJqL-0004wM-2P for pgsql-hackers@arkaria.postgresql.org; Mon, 26 Nov 2018 16:34:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gRJqJ-0003H2-R0 for pgsql-hackers@arkaria.postgresql.org; Mon, 26 Nov 2018 16:34:39 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gRJqJ-0003Gv-JQ for pgsql-hackers@lists.postgresql.org; Mon, 26 Nov 2018 16:34:39 +0000 Received: from ping.uio.no ([2001:700:100:570::196]) by magus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gRJqH-0004NE-9X for pgsql-hackers@postgresql.org; Mon, 26 Nov 2018 16:34:38 +0000 Received: from [2001:700:100:570::211] (helo=dalvik.ping.uio.no ident=Debian-exim) by ping.uio.no with esmtp (Exim 4.72 #1 (Debian)) id 1gRJqC-0005D8-VK for ; Mon, 26 Nov 2018 17:34:35 +0100 Received: from ilmari by dalvik.ping.uio.no with local (Exim 4.84_2) (envelope-from ) id 1gRJqC-0000Ub-Oa for pgsql-hackers@postgresql.org; Mon, 26 Nov 2018 17:34:32 +0100 From: ilmari@ilmari.org (Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?=) To: pgsql-hackers@postgresql.org Subject: [PATCH] Improve tab completion for CREATE TABLE Date: Mon, 26 Nov 2018 16:34:32 +0000 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Exiscan-Spam-Score: -3.7 (---) X-Exiscan-Spam-Report: SpamAssassin 3.3.1 (2010-03-16) on pike.ping.uio.no Score Rule * -5.0 PING_UIO_MAIL_IS_INTERNAL Message has never been outside * 129.240.0.0/16 or 193.157.115.0/24 * 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --=-=-= Content-Type: text/plain 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 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Tab-complete-more-options-for-CREATE-TABLE.patch From ed15e53b370d8ee4320961f17ed66cbf60621d28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= 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 */ + 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 --=-=-=--