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 1gRK4w-0005c3-Q9 for pgsql-hackers@arkaria.postgresql.org; Mon, 26 Nov 2018 16:49:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gRK4v-0003nf-Dh for pgsql-hackers@arkaria.postgresql.org; Mon, 26 Nov 2018 16:49:45 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gRK4v-0003nW-31 for pgsql-hackers@lists.postgresql.org; Mon, 26 Nov 2018 16:49:45 +0000 Received: from ping.uio.no ([2001:700:100:570::196]) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gRK4s-0002Xv-4V for pgsql-hackers@postgresql.org; Mon, 26 Nov 2018 16:49:43 +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 1gRK4m-0006VG-10 for ; Mon, 26 Nov 2018 17:49:38 +0100 Received: from ilmari by dalvik.ping.uio.no with local (Exim 4.84_2) (envelope-from ) id 1gRK4l-0000W6-T7 for pgsql-hackers@postgresql.org; Mon, 26 Nov 2018 17:49:35 +0100 From: ilmari@ilmari.org (Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?=) To: pgsql-hackers@postgresql.org Subject: [PATCH] Tiny CREATE STATISTICS tab-completion cleanup Date: Mon, 26 Nov 2018 16:49:35 +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, As I was hacking on the CREATE TABLE tab completions, I noticed that the CREATE STATISTICS completion was checking manually for the start and end of the parenthesised list instead of using the "(*)" wildcard (because it predates that functionality). Attached is a patch that updates it to use the modern syntax. - ilmari -- "I use RMS as a guide in the same way that a boat captain would use a lighthouse. It's good to know where it is, but you generally don't want to find yourself in the same spot." - Tollef Fog Heen --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Use-wildcard-to-match-parens-after-CREATE-STATISTICS.patch From dc4940b937f3e3d51fb76bfa970aac15be9476d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= Date: Fri, 23 Nov 2018 15:21:22 +0000 Subject: [PATCH 1/2] Use wildcard to match parens after CREATE STATISTICS Now that * can match in the middle of an alternative, we can use "(*)" to match the whole parenthesised list, instead of checking manually for the '(' and ')'. --- src/bin/psql/tab-complete.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 9dbd555166..90cc1fe215 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -2390,9 +2390,7 @@ psql_completion(const char *text, int start, int end) COMPLETE_WITH("(", "ON"); else if (Matches("CREATE", "STATISTICS", MatchAny, "(")) COMPLETE_WITH("ndistinct", "dependencies"); - else if (HeadMatches("CREATE", "STATISTICS", MatchAny) && - previous_words[0][0] == '(' && - previous_words[0][strlen(previous_words[0]) - 1] == ')') + else if (Matches("CREATE", "STATISTICS", MatchAny, "(*)")) COMPLETE_WITH("ON"); else if (HeadMatches("CREATE", "STATISTICS", MatchAny) && TailMatches("FROM")) -- 2.19.2 --=-=-=--