Re: psql: Fix tab completion for VACUUM option values

From: Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: psql: Fix tab completion for VACUUM option values
Date: 2025-12-23 01:37:49
Message-ID: 20251223103749.9d94b1fdcc13d7f7853bdaf7@sraoss.co.jp
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 22 Dec 2025 13:55:59 -0800
Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:

> Hi,
>
> On Mon, Dec 22, 2025 at 9:15 AM Yugo Nagata <nagata(at)sraoss(dot)co(dot)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(at)sraoss(dot)co(dot)jp>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2025-12-23 01:41:41 Re: [PATCH] Add memory usage reporting to VACUUM VERBOSE
Previous Message Shixin Wang 2025-12-23 01:25:27 Re: Fix wrong reference in pg_overexplain's doc