[PATCH v1] Fix tab completion for DROP INDEX CONCURRENTLY

Started by Sho Ito4 days ago11 messageshackers
Beta feature

Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.

won't retrysuccessCI history

This thread has been committed, so CI has stopped here. Anything below is the last result it produced.

You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:

docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t254267
psql -h localhost -U postgres

Built from patchset v6 (message #6), October 21, 2026 at 05:26 AM.

Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:

git clone --branch t254267_6 https://github.com/hackorum-dev/postgres.git

In a checkout you already have, add the fork once:

git remote add hackorum https://github.com/hackorum-dev/postgres.git

then, for this patchset and every later one:

git fetch hackorum t254267_6 && git checkout t254267_6

Patchset v6 (message #6) is on t254267_6

Jump to latest
#1Sho Ito
i.sho.0628@gmail.com

Hi,

psql currently offers `CASCADE` after `DROP INDEX CONCURRENTLY
<index_name>`,
although the backend rejects that combination [1]https://github.com/postgres/postgres/blob/3138f248cd3de43dd0f96760fc666152ea8a5c37/src/backend/commands/tablecmds.c#L1590-L1593.

The attached patch limits completion to `RESTRICT` for concurrent index
drops. Ordinary `DROP INDEX` continues to offer both `CASCADE` and
`RESTRICT`.

[1]: https://github.com/postgres/postgres/blob/3138f248cd3de43dd0f96760fc666152ea8a5c37/src/backend/commands/tablecmds.c#L1590-L1593
https://github.com/postgres/postgres/blob/3138f248cd3de43dd0f96760fc666152ea8a5c37/src/backend/commands/tablecmds.c#L1590-L1593

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/&gt;*
GitHub: https://github.com/sean0628/
=======================================

Attachments:

t254267_1
v1-0001-Fix-tab-completion-for-DROP-INDEX-CONCURRENTLY.patchapplication/octet-stream; name=v1-0001-Fix-tab-completion-for-DROP-INDEX-CONCURRENTLY.patchDownload+1-2
#2Fujii Masao
masao.fujii@gmail.com
In reply to: Sho Ito (#1)
Re: [PATCH v1] Fix tab completion for DROP INDEX CONCURRENTLY

On Mon, Oct 19, 2026 at 12:03 PM Sho Ito <i.sho.0628@gmail.com> wrote:

The attached patch limits completion to `RESTRICT` for concurrent index
drops. Ordinary `DROP INDEX` continues to offer both `CASCADE` and `RESTRICT`.

Thanks for the patch! LGTM.

This patch should be backpatched to all supported versions?

Regards,

--
Fujii Masao

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

On Oct 19, 2026, at 11:02, Sho Ito <i.sho.0628@gmail.com> wrote:

Hi,

psql currently offers `CASCADE` after `DROP INDEX CONCURRENTLY <index_name>`,
although the backend rejects that combination [1].

The attached patch limits completion to `RESTRICT` for concurrent index
drops. Ordinary `DROP INDEX` continues to offer both `CASCADE` and `RESTRICT`.

[1] https://github.com/postgres/postgres/blob/3138f248cd3de43dd0f96760fc666152ea8a5c37/src/backend/commands/tablecmds.c#L1590-L1593

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-DROP-INDEX-CONCURRENTLY.patch>

Good catch.
```
evantest=# DROP INDEX CONCURRENTLY i
CASCADE RESTRICT
evantest=# DROP INDEX CONCURRENTLY i cascade;
ERROR: DROP INDEX CONCURRENTLY does not support CASCADE
```

The fix looks good to me. I also verified that it only removes “CASCADE” from “DROP INDEX CONCURRENTLY”, while “DROP INDEX” is not affected.

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

#4Sho Ito
i.sho.0628@gmail.com
In reply to: Chao Li (#3)
Re: [PATCH v1] Fix tab completion for DROP INDEX CONCURRENTLY

Hi Fujii-san,

This patch should be backpatched to all supported versions?

Yes, backpatching down to v14 sounds reasonable to me.
I can help prepare branch-specific patches if needed.

Thanks to you and Chao for reviewing the patch.

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/&gt;*
GitHub: https://github.com/sean0628/
=======================================

#5shihao zhong
zhong950419@gmail.com
In reply to: Fujii Masao (#2)
Re: [PATCH v1] Fix tab completion for DROP INDEX CONCURRENTLY

Hi Sho,

Thanks for the patch.

One small thing I noticed. With only RESTRICT left, Tab now fills it in
directly.
Since RESTRICT is the default, it may not help much, and
"DROP INDEX CONCURRENTLY IF " plus Tab becomes
"IF RESTRICT". Maybe we could just remove the rule?

Thanks,
Shihao

#6Sho Ito
i.sho.0628@gmail.com
In reply to: shihao zhong (#5)
Re: [PATCH v1] Fix tab completion for DROP INDEX CONCURRENTLY

On Wed, Oct 21, 2026 at 9:21 AM shihao zhong <zhong950419@gmail.com> wrote:

Since RESTRICT is the default, it may not help much, and
"DROP INDEX CONCURRENTLY IF " plus Tab becomes
"IF RESTRICT". Maybe we could just remove the rule?

Hi Shihao,

Agreed. Since `RESTRICT` is the default, there is little benefit in offering
it here. I'll remove the rule in v2.

Thanks for the review!

Sho

--
=======================================
*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/&gt;*
GitHub: https://github.com/sean0628/
=======================================

Attachments:

t254267_6
v2-0001-Fix-tab-completion-for-DROP-INDEX-CONCURRENTLY.patchapplication/octet-stream; name=v2-0001-Fix-tab-completion-for-DROP-INDEX-CONCURRENTLY.patchDownload+0-3
#7Fujii Masao
masao.fujii@gmail.com
In reply to: Sho Ito (#6)
Re: [PATCH v1] Fix tab completion for DROP INDEX CONCURRENTLY

On Wed, Oct 21, 2026 at 2:12 PM Sho Ito <i.sho.0628@gmail.com> wrote:

Agreed. Since `RESTRICT` is the default, there is little benefit in offering
it here.

We already offer completion for optional clauses that make the default explicit,
such as WITH after REFRESH MATERIALIZED VIEW CONCURRENTLY <name>.
So I think v1 is fine too.

Regards,

--
Fujii Masao

#8Sho Ito
i.sho.0628@gmail.com
In reply to: Fujii Masao (#7)
Re: [PATCH v1] Fix tab completion for DROP INDEX CONCURRENTLY

On Wed, Oct 21, 2026 at 4:15 PM Fujii Masao <masao.fujii@gmail.com> wrote:

We already offer completion for optional clauses that make the default
explicit,
such as WITH after REFRESH MATERIALIZED VIEW CONCURRENTLY <name>.
So I think v1 is fine too.

Hi Fujii-san,

Thanks, that makes sense. How about keeping v1 for now and addressing
the incorrect completion after `IF` separately by improving completion
for `IF EXISTS` in the affected `DROP` commands?

Shihao, would that work for you?

Regards,
Sho

--
=======================================
*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/&gt;*
GitHub: https://github.com/sean0628/
=======================================

#9Fujii Masao
masao.fujii@gmail.com
In reply to: Sho Ito (#8)
Re: [PATCH v1] Fix tab completion for DROP INDEX CONCURRENTLY

On Wed, Oct 21, 2026 at 4:34 PM Sho Ito <i.sho.0628@gmail.com> wrote:

Thanks, that makes sense. How about keeping v1 for now

+1

and addressing
the incorrect completion after `IF` separately by improving completion
for `IF EXISTS` in the affected `DROP` commands?

IIUC, currently, psql does not offer tab completion for "IF EXISTS" or
"IF NOT EXISTS". But, are you suggesting adding support for these clauses
across commands? I'm not sure how much benefit this would provide
relative to the implementation effort.

BTW, since "if" is not a reserved keyword, an index can be named "if".
What should tab completion offer after "DROP INDEX CONCURRENTLY if"
in that case?

Regards,

--
Fujii Masao

#10Fujii Masao
masao.fujii@gmail.com
In reply to: Fujii Masao (#9)
Re: [PATCH v1] Fix tab completion for DROP INDEX CONCURRENTLY

On Wed, Oct 21, 2026 at 5:44 PM Fujii Masao <masao.fujii@gmail.com> wrote:

On Wed, Oct 21, 2026 at 4:34 PM Sho Ito <i.sho.0628@gmail.com> wrote:

Thanks, that makes sense. How about keeping v1 for now

+1

I've pushed v1. Thanks!

Regards,

--
Fujii Masao

#11Sho Ito
i.sho.0628@gmail.com
In reply to: Fujii Masao (#10)
Re: [PATCH v1] Fix tab completion for DROP INDEX CONCURRENTLY

Fujii Masao wrote:

BTW, since "if" is not a reserved keyword, an index can be named "if".
What should tab completion offer after "DROP INDEX CONCURRENTLY if"
in that case?

Hi Fujii-san,

You're right. I had the affected `DROP` commands in mind, but hadn't
considered an index named `if`. In that case, `RESTRICT` is a valid
completion, so calling the completion after `IF` incorrect was too broad.

I agree that broader `IF [NOT] EXISTS` support would need more thought,
and don't plan to pursue it for now.

Thanks for the review and for committing v1!

Regards,
Sho

--
=======================================
*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/&gt;*
GitHub: https://github.com/sean0628/
=======================================