Re: Several problems in tab-completions for SET/RESET - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Several problems in tab-completions for SET/RESET
Date
Msg-id CAB7nPqQj=Q7myfuegRFQBjOWh96k9OFvJdgcK+EkimwHNb-VZw@mail.gmail.com
Whole thread Raw
In response to Several problems in tab-completions for SET/RESET  (Fujii Masao <masao.fujii@gmail.com>)
Responses Re: Several problems in tab-completions for SET/RESET  (Masahiko Sawada <sawada.mshk@gmail.com>)
Re: Several problems in tab-completions for SET/RESET  (Fujii Masao <masao.fujii@gmail.com>)
List pgsql-hackers
On Thu, Jan 28, 2016 at 9:32 PM, Fujii Masao <masao.fujii@gmail.com> wrote:
> I found that the following tab-completions for SET/RESET which
> worked properly before doesn't work properly now in the master.
>
> 1. ALTER SYSTEM SET|RESET <tab> lists nothing.
> 2. ALTER DATABASE xxx SET <tab> lists nothing.
> 3. ALTER DATABASE xxx SET yyy <tab> lists nothing.
> 4. ALTER DATABASE xxx SET datestyle TO <tab> lists nothing.
>
> Attached patch fixes those problems.

-       else if (Matches4("ALTER", "SYSTEM", "SET|RESET", MatchAny))
+       else if (Matches3("ALTER", "SYSTEM", "SET|RESET"))
Good catch.

-       else if (Matches2("SET", MatchAny))
+       else if (TailMatches2("SET", MatchAny) &&
+                        !TailMatches4("UPDATE|DOMAIN", MatchAny,
MatchAny, MatchAny) &&
+                        !TailMatches1("TABLESPACE|SCHEMA") &&
+                        !ends_with(prev_wd, ')') &&
+                        !ends_with(prev_wd, '='))               COMPLETE_WITH_CONST("TO");
This gets... unreadable.

In order to maximize the amount of Matches() used, wouldn't it be
better to complete a bit more the list of completions directly in
ALTER DATABASE? This would make the code more readable.
-- 
Michael



pgsql-hackers by date:

Previous
From: Masahiko Sawada
Date:
Subject: Re: Support for N synchronous standby servers - take 2
Next
From: Amit Langote
Date:
Subject: Re: [PROPOSAL] VACUUM Progress Checker.