[PATCH] Misleading error message for REPACK USING INDEX on shared catalogs

Started by Devrim GÜNDÜZ2 months ago4 messageshackers
Jump to latest
#1Devrim GÜNDÜZ
devrim@gunduz.org

Hi,

While poking at REPACK on v19 beta4 for my Chicago meetup talk, I
noticed that the error message emitted when trying to REPACK a shared
catalog with USING INDEX is misleading, since it makes it sound like
REPACK itself is disallowed on shared catalogs, when only the USING
INDEX form is:

postgres=# REPACK pg_authid USING INDEX pg_authid_oid_index;
ERROR: cannot execute REPACK on a shared catalog

postgres=# REPACK pg_authid;
REPACK

The restriction is intentional in repack.c, but the errmsg() text
doesn't convey that the restriction is specific to the USING INDEX form,
so for a while I thought I found a bug.

Attached patch tweaks the message to name USING INDEX specifically,
and also includes the related comment in repack.c to an errdetail() so
it's visible to the user, not just to someone reading the source:

ERROR: cannot execute REPACK USING INDEX on a shared catalog
DETAIL: Marking an index as clustered on a shared catalog would
only take effect in the current database.

Regards,
--
Devrim Gündüz
Open Source Solution Architect, PostgreSQL Major Contributor
BlueSky: @devrim.gunduz.org , @gunduz.org

Attachments:

t253904_1
repack_shared_catalog_errmsg.patchtext/x-patch; charset=UTF-8; name=repack_shared_catalog_errmsg.patchDownload+3-2
#2Chao Li
li.evan.chao@gmail.com
In reply to: Devrim GÜNDÜZ (#1)
Re: [PATCH] Misleading error message for REPACK USING INDEX on shared catalogs

On Sep 23, 2026, at 06:05, Devrim Gündüz <devrim@gunduz.org> wrote:

Hi,

While poking at REPACK on v19 beta4 for my Chicago meetup talk, I
noticed that the error message emitted when trying to REPACK a shared
catalog with USING INDEX is misleading, since it makes it sound like
REPACK itself is disallowed on shared catalogs, when only the USING
INDEX form is:

postgres=# REPACK pg_authid USING INDEX pg_authid_oid_index;
ERROR: cannot execute REPACK on a shared catalog

postgres=# REPACK pg_authid;
REPACK

The restriction is intentional in repack.c, but the errmsg() text
doesn't convey that the restriction is specific to the USING INDEX form,
so for a while I thought I found a bug.

Attached patch tweaks the message to name USING INDEX specifically,
and also includes the related comment in repack.c to an errdetail() so
it's visible to the user, not just to someone reading the source:

ERROR: cannot execute REPACK USING INDEX on a shared catalog
DETAIL: Marking an index as clustered on a shared catalog would
only take effect in the current database.

Regards,
--
Devrim Gündüz
Open Source Solution Architect, PostgreSQL Major Contributor
BlueSky: @devrim.gunduz.org , @gunduz.org
<repack_shared_catalog_errmsg.patch>

+1. The commend and the code have clearly shown that repacking on shared catalogs are allowed, but USING INDEX is not allowed.

But I have concern with the change. cluster_rel() is used by both REPACK and CLUSTER commands, but CLUSTER command, the syntax is CLUSTER … USING index-name.

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

#3Alvaro Herrera
alvherre@kurilemu.de
In reply to: Chao Li (#2)
Re: [PATCH] Misleading error message for REPACK USING INDEX on shared catalogs

On 2026-Sep-23, Chao Li wrote:

On Sep 23, 2026, at 06:05, Devrim Gündüz <devrim@gunduz.org> wrote:

While poking at REPACK on v19 beta4 for my Chicago meetup talk, I
noticed that the error message emitted when trying to REPACK a shared
catalog with USING INDEX is misleading, since it makes it sound like
REPACK itself is disallowed on shared catalogs, when only the USING
INDEX form is:

postgres=# REPACK pg_authid USING INDEX pg_authid_oid_index;
ERROR: cannot execute REPACK on a shared catalog

postgres=# REPACK pg_authid;
REPACK

Good catch.

Attached patch tweaks the message to name USING INDEX specifically,
and also includes the related comment in repack.c to an errdetail() so
it's visible to the user, not just to someone reading the source:

ERROR: cannot execute REPACK USING INDEX on a shared catalog
DETAIL: Marking an index as clustered on a shared catalog would
only take effect in the current database.

Looks reasonable.

But I have concern with the change. cluster_rel() is used by both
REPACK and CLUSTER commands, but CLUSTER command, the syntax is
CLUSTER … USING index-name.

Yeah, I think we should keep the "cannot execute %s on a shared catalog"
string as is, and make the SQL bit interpolated there be REPACK USING
INDEX or CLUSTER according to stmt->cmd; one because CLUSTER also allows
the older CLUSTER ON syntax AFAIR, but also you can't do CLUSTER with no
index.

The added errdetail() bit looks good to me. This is not a new omission:
the older cluster.c code also lacked it. (The errmsg was "cannot
cluster a shared catalog".)

--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/

#4Alvaro Herrera
alvherre@kurilemu.de
In reply to: Alvaro Herrera (#3)
Re: [PATCH] Misleading error message for REPACK USING INDEX on shared catalogs

On 2026-Sep-23, Álvaro Herrera wrote:

On 2026-Sep-23, Chao Li wrote:

But I have concern with the change. cluster_rel() is used by both
REPACK and CLUSTER commands, but CLUSTER command, the syntax is
CLUSTER … USING index-name.

Yeah, I think we should keep the "cannot execute %s on a shared catalog"
string as is, and make the SQL bit interpolated there be REPACK USING
INDEX or CLUSTER according to stmt->cmd; one because CLUSTER also allows
the older CLUSTER ON syntax AFAIR, but also you can't do CLUSTER with no
index.

Pushed like this, thanks.

--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
"I suspect most samba developers are already technically insane...
Of course, since many of them are Australians, you can't tell." (L. Torvalds)