[PATCH v1] Fix tab completion for REINDEX SYSTEM

Started by Sho Ito13 days ago3 messageshackers
Jump to latest
#1Sho Ito
i.sho.0628@gmail.com

Hi,

psql currently offers `CONCURRENTLY` after `REINDEX SYSTEM`, although
the backend rejects that combination [1]https://github.com/postgres/postgres/blob/3138f248cd3de43dd0f96760fc666152ea8a5c37/src/backend/commands/indexcmds.c#L3317-L3321.

The attached patch completes only database names after `REINDEX SYSTEM`,
including when parenthesized options are present.

[1]: https://github.com/postgres/postgres/blob/3138f248cd3de43dd0f96760fc666152ea8a5c37/src/backend/commands/indexcmds.c#L3317-L3321
https://github.com/postgres/postgres/blob/3138f248cd3de43dd0f96760fc666152ea8a5c37/src/backend/commands/indexcmds.c#L3317-L3321

Kind regards,
Sho Ito

--
=======================================
*Sho Ito (Sean)*

E-mail: i.sho.0628@gmail.com
LinkedIn: *https://www.linkedin.com/in/sho-ito-0628/
<https://www.linkedin.com/in/sho-ito-0628/>*
GitHub: https://github.com/sean0628/
=======================================

Attachments:

t254355_1
v1-0001-Fix-tab-completion-for-REINDEX-SYSTEM.patchapplication/octet-stream; name=v1-0001-Fix-tab-completion-for-REINDEX-SYSTEM.patchDownload+7-5
#2Ishjaap Singh
ishjaap.singh07@gmail.com
In reply to: Sho Ito (#1)
Re: [PATCH v1] Fix tab completion for REINDEX SYSTEM

On Fri, Oct 23, 2026 at 13:39, Sho Ito wrote:

psql currently offers `CONCURRENTLY` after `REINDEX SYSTEM`, although
the backend rejects that combination [1].

Hi Sho,

I tested v1 on master (022a80fe6c1) with a readline build.

Before the patch, REINDEX SYSTEM <Tab><Tab> offers CONCURRENTLY, and
CON<Tab> completes to REINDEX SYSTEM CONCURRENTLY, which the server
rejects ("cannot reindex system catalogs concurrently").

With v1, REINDEX SYSTEM offers only database names, including with
parenthesized options and lowercase input, and CON<Tab> no longer
completes to CONCURRENTLY there. The DATABASE, TABLE, INDEX and SCHEMA
forms are unchanged. The psql TAP tests pass and pgindent is clean.

For backpatching: v1 applies as-is to REL_18 and REL_19, and to
REL_15-REL_17 once the file is renamed to tab-complete.c; REL_14 would
need a manual adjustment. These are applicability checks only; I
didn't build or test the stable branches.

Looks good to me.

Thanks,
Ishjaap Singh

#3Chao Li
li.evan.chao@gmail.com
In reply to: Sho Ito (#1)
Re: [PATCH v1] Fix tab completion for REINDEX SYSTEM

On Oct 23, 2026, at 21:39, Sho Ito <i.sho.0628@gmail.com> wrote:

Hi,

psql currently offers `CONCURRENTLY` after `REINDEX SYSTEM`, although
the backend rejects that combination [1].

The attached patch completes only database names after `REINDEX SYSTEM`,
including when parenthesized options are present.

[1] https://github.com/postgres/postgres/blob/3138f248cd3de43dd0f96760fc666152ea8a5c37/src/backend/commands/indexcmds.c#L3317-L3321

Kind regards,
Sho Ito

--
=======================================
Sho Ito (Sean)

E-mail: i.sho.0628@gmail.com
LinkedIn: https://www.linkedin.com/in/sho-ito-0628/
GitHub: https://github.com/sean0628/
=======================================
<v1-0001-Fix-tab-completion-for-REINDEX-SYSTEM.patch>

LGTM. My local tests also show that v1 preserves the existing behavior for REINDEX DATABASE while removing the unsupported CONCURRENTLY suggestion for REINDEX SYSTEM.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/