pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
[PATCH] Misleading error message for REPACK USING INDEX on shared catalogs
3+ messages / 3 participants
[nested] [flat]

* [PATCH] Misleading error message for REPACK USING INDEX on shared catalogs
@ 2026-09-22 22:05 Devrim Gündüz <devrim@gunduz.org>
  2026-09-23 06:32 ` Re: [PATCH] Misleading error message for REPACK USING INDEX on shared catalogs Chao Li <li.evan.chao@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Devrim Gündüz @ 2026-09-22 22:05 UTC (permalink / raw)
  To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.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:

  [text/x-patch] repack_shared_catalog_errmsg.patch (620B, ../../4dbba6c413bad017217bfcace43a0f33fc921eb2.camel@gunduz.org/2-repack_shared_catalog_errmsg.patch)
  download | inline diff:
--- a/src/backend/commands/repack.c
+++ b/src/backend/commands/repack.c
@@ -577,8 +577,9 @@
 		ereport(ERROR,
 				errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
 		/*- translator: first %s is name of a SQL command, eg. REPACK */
-				errmsg("cannot execute %s on a shared catalog",
-					   RepackCommandAsString(cmd)));
+				errmsg("cannot execute %s USING INDEX on a shared catalog",
+					   RepackCommandAsString(cmd)),
+				errdetail("Marking an index as clustered on a shared catalog would only take effect in the current database."));
 
 	/*
 	 * The CONCURRENTLY case should have been rejected earlier because it does


  [application/pgp-signature] signature.asc (857B, ../../4dbba6c413bad017217bfcace43a0f33fc921eb2.camel@gunduz.org/3-signature.asc)
  download

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: [PATCH] Misleading error message for REPACK USING INDEX on shared catalogs
  2026-09-22 22:05 [PATCH] Misleading error message for REPACK USING INDEX on shared catalogs Devrim Gündüz <devrim@gunduz.org>
@ 2026-09-23 06:32 ` Chao Li <li.evan.chao@gmail.com>
  2026-09-23 08:36   ` Re: [PATCH] Misleading error message for REPACK USING INDEX on shared catalogs Álvaro Herrera <alvherre@kurilemu.de>
  0 siblings, 1 reply; 3+ messages in thread

From: Chao Li @ 2026-09-23 06:32 UTC (permalink / raw)
  To: Devrim Gündüz <devrim@gunduz.org>; +Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>



> 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/










^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: [PATCH] Misleading error message for REPACK USING INDEX on shared catalogs
  2026-09-22 22:05 [PATCH] Misleading error message for REPACK USING INDEX on shared catalogs Devrim Gündüz <devrim@gunduz.org>
  2026-09-23 06:32 ` Re: [PATCH] Misleading error message for REPACK USING INDEX on shared catalogs Chao Li <li.evan.chao@gmail.com>
@ 2026-09-23 08:36   ` Álvaro Herrera <alvherre@kurilemu.de>
  0 siblings, 0 replies; 3+ messages in thread

From: Álvaro Herrera @ 2026-09-23 08:36 UTC (permalink / raw)
  To: Chao Li <li.evan.chao@gmail.com>; +Cc: Devrim Gündüz <devrim@gunduz.org>; PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>

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/






^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2026-09-23 08:36 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-09-22 22:05 [PATCH] Misleading error message for REPACK USING INDEX on shared catalogs Devrim Gündüz <devrim@gunduz.org>
2026-09-23 06:32 ` Chao Li <li.evan.chao@gmail.com>
2026-09-23 08:36   ` Álvaro Herrera <alvherre@kurilemu.de>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox