Re: psql: Fix tab completion for VACUUM option values - Mailing list pgsql-hackers

From Yugo Nagata
Subject Re: psql: Fix tab completion for VACUUM option values
Date
Msg-id 20251223103749.9d94b1fdcc13d7f7853bdaf7@sraoss.co.jp
Whole thread Raw
In response to Re: psql: Fix tab completion for VACUUM option values  (Masahiko Sawada <sawada.mshk@gmail.com>)
List pgsql-hackers
On Mon, 22 Dec 2025 13:55:59 -0800
Masahiko Sawada <sawada.mshk@gmail.com> wrote:

> Hi,
> 
> On Mon, Dec 22, 2025 at 9:15 AM Yugo Nagata <nagata@sraoss.co.jp> wrote:
> >
> > Hi,
> >
> > I noticed that tab completion for VACUUM option values is broken.
> > For example, ON or OFF should be suggested after
> > "VACUUM (VERBOSE", but this currently does not work.
> >
> > I believe this issue was introduced by commit 8a3e4011, which added
> > tab completion for the ONLY option of VACUUM and ANALYZE, along with
> > some code simplification using MatchAnyN.
> >
> > In addition, tab completion for the ONLY option is insufficient:
> > "ONLY" is not suggested immediately after a completed option list,
> > for example in "VACUUM (...) ONLY" or "ANALYZE (...) ONLY".
> >
> > I've attached a patch to fix these issues.
> >
> 
> I agree with your analysis. I think the patch should be backpatched to v18

Thank you for your review! I agree that this should be backpatched to v18.
 
> FYI due to the simplification by using MatchAnyN, vacuum options are
> suggested at inappropriate positions:
> 
> postgres(1:2376453)=# vacuum (verbose on) freeze
> ANALYZE              ONLY                 VERBOSE
> information_schema.  public.              t
> 
> Given that it's not common usage, we can live with that.

Similar inappropriate suggestions can occur in other cases where
MatchAnyN is used. For example:

postgres=# truncate only t cascade restart identity 
CASCADE   RESTRICT  

However, I also agree that this behavior is acceptable, since it is
unlikely to be encountered when users follow the tab completion
suggested by psql.

Regards,
Yugo Nagata

-- 
Yugo Nagata <nagata@sraoss.co.jp>



pgsql-hackers by date:

Previous
From: Shixin Wang
Date:
Subject: Re: Fix wrong reference in pg_overexplain's doc
Next
From: Chao Li
Date:
Subject: Re: [PATCH] Add memory usage reporting to VACUUM VERBOSE