psql: Fix tab completion for VACUUM option values
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.
Regards,
Yugo Nagata
--
Yugo Nagata <nagata@sraoss.co.jp>
Attachments:
0001-psql-Fix-tab-completion-for-VACUUM-option-values.patchtext/x-diff; name=0001-psql-Fix-tab-completion-for-VACUUM-option-values.patchDownload+24-19
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
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.
Regards,
--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com
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. tGiven 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>
On Mon, Dec 22, 2025 at 5:37 PM Yugo Nagata <nagata@sraoss.co.jp> wrote:
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. tGiven 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
Right.
I've pushed the patch.
Regards,
--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com