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] Tiny CREATE STATISTICS tab-completion cleanup
Date: Mon, 26 Nov 2018 16:49:35 +0000
Message-ID: <d8jwooziy1s.fsf@dalvik.ping.uio.no> (raw)

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

Attachments:

0001-Use-wildcard-to-match-parens-after-CREATE-STATISTICS.patch (text/x-diff, 1.2K) download From dc4940b937f3e3d51fb76bfa970aac15be9476d2 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: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

view thread (3+ messages)  latest in thread

Message-ID: <d8jwooziy1s.fsf@dalvik.ping.uio.no>
Permalink:  ../d8jwooziy1s.fsf@dalvik.ping.uio.no/
Also on:    postgresql.org/message-id/d8jwooziy1s.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] Tiny CREATE STATISTICS tab-completion cleanup
  In-Reply-To: <d8jwooziy1s.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