[PATCH] Tiny CREATE STATISTICS tab-completion cleanup

Поиск
Список
Период
Сортировка
От ilmari@ilmari.org (Dagfinn Ilmari Mannsåker)
Тема [PATCH] Tiny CREATE STATISTICS tab-completion cleanup
Дата
Msg-id d8jwooziy1s.fsf@dalvik.ping.uio.no
обсуждение исходный текст
Ответы Re: [PATCH] Tiny CREATE STATISTICS tab-completion cleanup  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
Список pgsql-hackers
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

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


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

Предыдущее
От: Andrey Borodin
Дата:
Сообщение: Re: B-tree cache prefetches
Следующее
От: Andrey Borodin
Дата:
Сообщение: Re: Covering GiST indexes