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