On Thu, Jan 28, 2016 at 10:15 PM, Michael Paquier
<michael.paqu...@gmail.com> wrote:
> On Thu, Jan 28, 2016 at 9:32 PM, Fujii Masao <masao.fu...@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 change breaks tab completion for ALTER TABLE ... SET
[WITH/LOGGED/UNLOGGED].

It think it should be
> +       else if (Matches2("SET", MatchAny) &&

Related to it, I found tab completion for ALTER TABLE .. SET WITH,
which doesn't working well.
Patch is attached.

Regards,

--
Masahiko Sawada
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 008f3cb..033df74 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -1758,6 +1758,8 @@ psql_completion(const char *text, int start, int end)
 	else if (Matches5("ALTER", "TABLE", MatchAny, "SET", "WITHOUT"))
 		COMPLETE_WITH_LIST2("CLUSTER", "OIDS");
 	/* ALTER TABLE <foo> RESET */
+	else if (Matches5("ALTER", "TABLE", MatchAny, "SET", "WITH"))
+		COMPLETE_WITH_CONST("OIDS");
 	else if (Matches4("ALTER", "TABLE", MatchAny, "RESET"))
 		COMPLETE_WITH_CONST("(");
 	/* ALTER TABLE <foo> SET|RESET ( */
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to