pg.ddx.io pgsql-hackers@postgresql.org mailing list archive
help / color / mirror / Atom feedREPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table
14+ messages / 5 participants
[nested] [flat]
Commits from this thread:
2026-09-09 4964c75b08 94cc8c443a Unify REPACK (CONCURRENTLY) error messages.
2026-09-08 86f7c82cf1 04bb150025 Restrict REPACK (CONCURRENTLY) on user catalog tables.
* REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table
@ 2026-08-27 14:22 Nathan Bossart <nathandbossart@gmail.com>
2026-08-27 22:46 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
0 siblings, 1 reply; 14+ messages in thread
From: Nathan Bossart @ 2026-08-27 14:22 UTC (permalink / raw)
To: pgsql-hackers; +Cc: alvherre@kurilemu.de
IIUC this can cause problems for logical replication consumers, since the
CONCURRENTLY path doesn't go through the rewriteheap.c machinery like the
non-concurrent path does:
CREATE TABLE t (a INT PRIMARY KEY, b TEXT) WITH (user_catalog_table = true);
ALTER TABLE t ALTER COLUMN b TYPE varchar(100); -- correctly fails
REPACK (CONCURRENTLY) t; -- should fail but doesn't
I believe the fix for v19 is to add a check for
RelationIsUsedAsCatalogTable() in check_concurrent_repack_requirements()
(plus a corresponding update to the list of CONCURRENTLY limitations in the
docs).
--
nathan
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table
2026-08-27 14:22 REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Nathan Bossart <nathandbossart@gmail.com>
@ 2026-08-27 22:46 ` Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-08-29 11:23 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Antonin Houska <ah@cybertec.at>
0 siblings, 1 reply; 14+ messages in thread
From: Bharath Rupireddy @ 2026-08-27 22:46 UTC (permalink / raw)
To: Nathan Bossart <nathandbossart@gmail.com>; +Cc: pgsql-hackers; alvherre@kurilemu.de
Hi,
On Thu, Aug 27, 2026 at 7:22 AM Nathan Bossart <nathandbossart@gmail.com> wrote:
>
> IIUC this can cause problems for logical replication consumers, since the
> CONCURRENTLY path doesn't go through the rewriteheap.c machinery like the
> non-concurrent path does:
>
> CREATE TABLE t (a INT PRIMARY KEY, b TEXT) WITH (user_catalog_table = true);
> ALTER TABLE t ALTER COLUMN b TYPE varchar(100); -- correctly fails
> REPACK (CONCURRENTLY) t; -- should fail but doesn't
>
> I believe the fix for v19 is to add a check for
> RelationIsUsedAsCatalogTable() in check_concurrent_repack_requirements()
> (plus a corresponding update to the list of CONCURRENTLY limitations in the
> docs).
That's correct. I verified that concurrent repack doesn't write the
pg_logical/mappings files, which decoding later needs to correctly map
the old tuple locations to the new ones after a rewrite, unlike
non-concurrent CLUSTER, VACUUM FULL and REPACK on a user catalog
table. I think restricting user catalog tables, rather than making
concurrent repack support them, is the right choice at this point in
the release cycle.
Please find attached a patch with the suggested doc change. I didn't
add a test, I don't think we need one.
--
Bharath Rupireddy
Amazon Web Services: https://aws.amazon.com
Attachments:
v1-0001-Restrict-concurrent-repack-on-user-catalog-tables.patch (application/octet-stream, 2.9K) download
From 4423be275ac65a7b0fc062ff319789d0205b2727 Mon Sep 17 00:00:00 2001
From: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Date: Thu, 27 Aug 2026 22:41:00 +0000
Subject: [PATCH v1] Restrict concurrent repack on user catalog tables.
Concurrent repack (28d534e2ae0) rewrites the table without going
through the rewriteheap.c machinery that the non-concurrent path
uses. That machinery logs old-to-new tuple location mappings
under pg_logical/mappings, which logical decoding uses to resolve
the cmin/cmax of catalog tuples relocated by the rewrite.
check_concurrent_repack_requirements() didn't check whether the
table is used as a catalog table.
A table declared with user_catalog_table can be read by an output
plugin during logical decoding. Without those mappings, such a
consumer can no longer resolve the relocated tuples and is
silently broken.
Fix by erroring out for tables used as catalog tables, the same
way a heap rewrite via ALTER TABLE already does, and document the
limitation.
Backpatch to v19, where concurrent repack was introduced.
Reported-by: Nathan Bossart <nathandbossart@gmail.com>
Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Discussion: https://postgr.es/m/apBIFWzHYOaG0auN%40nathan
Backpatch-through: 19
---
doc/src/sgml/ref/repack.sgml | 8 ++++++++
src/backend/commands/repack.c | 9 +++++++++
2 files changed, 17 insertions(+)
diff --git a/doc/src/sgml/ref/repack.sgml b/doc/src/sgml/ref/repack.sgml
index 0cb72b6b289..e2d5a34ba8b 100644
--- a/doc/src/sgml/ref/repack.sgml
+++ b/doc/src/sgml/ref/repack.sgml
@@ -285,6 +285,14 @@ REPACK [ ( <replaceable class="parameter">option</replaceable> [, ...] ) ] USING
</para>
</listitem>
+ <listitem>
+ <para>
+ The table is declared as a catalog table using the
+ <link linkend="reloption-user-catalog-table"><literal>user_catalog_table</literal></link>
+ storage parameter.
+ </para>
+ </listitem>
+
<listitem>
<para>
<command>REPACK</command> is executed inside a transaction block.
diff --git a/src/backend/commands/repack.c b/src/backend/commands/repack.c
index 477c86b2ba6..39751af24af 100644
--- a/src/backend/commands/repack.c
+++ b/src/backend/commands/repack.c
@@ -886,6 +886,15 @@ check_concurrent_repack_requirements(Relation rel, Oid *ident_idx_p)
errhint("%s is not supported for catalog relations.",
"REPACK (CONCURRENTLY)"));
+ /* The CONCURRENTLY path does not write logical rewrite mappings. */
+ if (RelationIsUsedAsCatalogTable(rel))
+ ereport(ERROR,
+ errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot execute %s on relation \"%s\"",
+ "REPACK (CONCURRENTLY)", RelationGetRelationName(rel)),
+ errhint("%s is not supported for tables used as catalog tables.",
+ "REPACK (CONCURRENTLY)"));
+
/*
* reorderbuffer.c does not seem to handle processing of TOAST relation
* alone.
--
2.47.3
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table
2026-08-27 14:22 REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Nathan Bossart <nathandbossart@gmail.com>
2026-08-27 22:46 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
@ 2026-08-29 11:23 ` Antonin Houska <ah@cybertec.at>
2026-08-29 15:34 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
0 siblings, 1 reply; 14+ messages in thread
From: Antonin Houska @ 2026-08-29 11:23 UTC (permalink / raw)
To: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>; +Cc: Nathan Bossart <nathandbossart@gmail.com>; pgsql-hackers; alvherre@kurilemu.de
Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com> wrote:
> Hi,
>
> On Thu, Aug 27, 2026 at 7:22 AM Nathan Bossart <nathandbossart@gmail.com> wrote:
> >
> > IIUC this can cause problems for logical replication consumers, since the
> > CONCURRENTLY path doesn't go through the rewriteheap.c machinery like the
> > non-concurrent path does:
> >
> > CREATE TABLE t (a INT PRIMARY KEY, b TEXT) WITH (user_catalog_table = true);
> > ALTER TABLE t ALTER COLUMN b TYPE varchar(100); -- correctly fails
> > REPACK (CONCURRENTLY) t; -- should fail but doesn't
> >
> > I believe the fix for v19 is to add a check for
> > RelationIsUsedAsCatalogTable() in check_concurrent_repack_requirements()
> > (plus a corresponding update to the list of CONCURRENTLY limitations in the
> > docs).
>
> That's correct. I verified that concurrent repack doesn't write the
> pg_logical/mappings files, which decoding later needs to correctly map
> the old tuple locations to the new ones after a rewrite, unlike
> non-concurrent CLUSTER, VACUUM FULL and REPACK on a user catalog
> table. I think restricting user catalog tables, rather than making
> concurrent repack support them, is the right choice at this point in
> the release cycle.
>
> Please find attached a patch with the suggested doc change. I didn't
> add a test, I don't think we need one.
Thanks! I'm just thinking about this comment:
+ /* The CONCURRENTLY path does not write logical rewrite mappings. */
IMO it makes no sense to rewrite the logical mappings as long as REPACK
(CONCURRENTLY) changes visibility information (i.e. it's MVCC-unsafe). Once we
implement the MVCC-safety, we should not remove this check unless we implement
the rewriting of the mappings for user catalog tables - that might also be
worth mentioning in the comment.
So far, I'd consider the MVCC-unsafety the primary reason to prohibit REPACK
(CONCURRENTLY) (or anyother MVCC-unsafe command) on the user catalog tables,
because it can make the contents of those tables invisible to the output
plugin at some point.
--
Antonin Houska
Web: https://www.cybertec-postgresql.com
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table
2026-08-27 14:22 REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Nathan Bossart <nathandbossart@gmail.com>
2026-08-27 22:46 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-08-29 11:23 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Antonin Houska <ah@cybertec.at>
@ 2026-08-29 15:34 ` Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-09-01 03:35 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
0 siblings, 1 reply; 14+ messages in thread
From: Bharath Rupireddy @ 2026-08-29 15:34 UTC (permalink / raw)
To: Antonin Houska <ah@cybertec.at>; +Cc: Nathan Bossart <nathandbossart@gmail.com>; pgsql-hackers; alvherre@kurilemu.de
Hi,
On Sat, Aug 29, 2026 at 4:23 AM Antonin Houska <ah@cybertec.at> wrote:
>
> Thanks! I'm just thinking about this comment:
>
> + /* The CONCURRENTLY path does not write logical rewrite mappings. */
>
> IMO it makes no sense to rewrite the logical mappings as long as REPACK
> (CONCURRENTLY) changes visibility information (i.e. it's MVCC-unsafe). Once we
> implement the MVCC-safety, we should not remove this check unless we implement
> the rewriting of the mappings for user catalog tables - that might also be
> worth mentioning in the comment.
>
> So far, I'd consider the MVCC-unsafety the primary reason to prohibit REPACK
> (CONCURRENTLY) (or anyother MVCC-unsafe command) on the user catalog tables,
> because it can make the contents of those tables invisible to the output
> plugin at some point.
Thanks for pointing this out. I read the docs related to MVCC-safety
of concurrent repack. I reworded the comment as you suggested. Feel
free to suggest changes to it if any. Please find the attached v2
patch.
--
Bharath Rupireddy
Amazon Web Services: https://aws.amazon.com
Attachments:
v2-0001-Restrict-REPACK-CONCURRENTLY-on-user-catalog-tabl.patch (application/octet-stream, 3.3K) download
From 71301630532b8aa8bb0e031b3c0b90a5365b4c25 Mon Sep 17 00:00:00 2001
From: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Date: Sat, 29 Aug 2026 15:15:47 +0000
Subject: [PATCH v2] Restrict REPACK (CONCURRENTLY) on user catalog tables.
Commit 28d534e2ae0 added the CONCURRENTLY option to REPACK.
Unlike the default path, which rewrites the table through
rewriteheap.c, the concurrent path is not MVCC-safe: it changes
the visibility information of the tuples it rewrites.
A table declared with the user_catalog_table storage parameter is
read by an output plugin during logical decoding, using
historical snapshots. Changing that visibility information can
make the table's contents invisible to the plugin at some point,
silently breaking decoding.
check_concurrent_repack_requirements() already rejects system
catalogs but did not consider tables used as catalog tables.
Reject those too, the same way a table rewrite via ALTER TABLE
already does, and document the limitation. Once REPACK
(CONCURRENTLY) is made MVCC-safe, this check should stay unless
the rewrite mappings are also written for user catalog tables.
Backpatch to v19, where REPACK (CONCURRENTLY) was introduced.
Reported-by: Nathan Bossart <nathandbossart@gmail.com>
Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Reviewed-by: Antonin Houska <ah@cybertec.at>
Discussion: https://postgr.es/m/apBIFWzHYOaG0auN%40nathan
Backpatch-through: 19
---
doc/src/sgml/ref/repack.sgml | 8 ++++++++
src/backend/commands/repack.c | 15 +++++++++++++++
2 files changed, 23 insertions(+)
diff --git a/doc/src/sgml/ref/repack.sgml b/doc/src/sgml/ref/repack.sgml
index 0cb72b6b289..e2d5a34ba8b 100644
--- a/doc/src/sgml/ref/repack.sgml
+++ b/doc/src/sgml/ref/repack.sgml
@@ -285,6 +285,14 @@ REPACK [ ( <replaceable class="parameter">option</replaceable> [, ...] ) ] USING
</para>
</listitem>
+ <listitem>
+ <para>
+ The table is declared as a catalog table using the
+ <link linkend="reloption-user-catalog-table"><literal>user_catalog_table</literal></link>
+ storage parameter.
+ </para>
+ </listitem>
+
<listitem>
<para>
<command>REPACK</command> is executed inside a transaction block.
diff --git a/src/backend/commands/repack.c b/src/backend/commands/repack.c
index 477c86b2ba6..829f76ac1d5 100644
--- a/src/backend/commands/repack.c
+++ b/src/backend/commands/repack.c
@@ -886,6 +886,21 @@ check_concurrent_repack_requirements(Relation rel, Oid *ident_idx_p)
errhint("%s is not supported for catalog relations.",
"REPACK (CONCURRENTLY)"));
+ /*
+ * REPACK (CONCURRENTLY) is not MVCC-safe, i.e. it changes visibility
+ * information, which can make the contents invisible to the output
+ * plugin. Once it is made MVCC-safe, the logical rewrite mappings must
+ * also be written for user catalog tables before this check can be
+ * removed.
+ */
+ if (RelationIsUsedAsCatalogTable(rel))
+ ereport(ERROR,
+ errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot execute %s on relation \"%s\"",
+ "REPACK (CONCURRENTLY)", RelationGetRelationName(rel)),
+ errhint("%s is not supported for tables used as catalog tables.",
+ "REPACK (CONCURRENTLY)"));
+
/*
* reorderbuffer.c does not seem to handle processing of TOAST relation
* alone.
--
2.47.3
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table
2026-08-27 14:22 REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Nathan Bossart <nathandbossart@gmail.com>
2026-08-27 22:46 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-08-29 11:23 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Antonin Houska <ah@cybertec.at>
2026-08-29 15:34 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
@ 2026-09-01 03:35 ` Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-09-04 18:02 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Masahiko Sawada <sawada.mshk@gmail.com>
0 siblings, 1 reply; 14+ messages in thread
From: Bharath Rupireddy @ 2026-09-01 03:35 UTC (permalink / raw)
To: Antonin Houska <ah@cybertec.at>; +Cc: Nathan Bossart <nathandbossart@gmail.com>; pgsql-hackers; alvherre@kurilemu.de
Hi,
On Sat, Aug 29, 2026 at 8:34 AM Bharath Rupireddy
<bharath.rupireddyforpostgres@gmail.com> wrote:
>
> Hi,
>
> On Sat, Aug 29, 2026 at 4:23 AM Antonin Houska <ah@cybertec.at> wrote:
> >
> > Thanks! I'm just thinking about this comment:
> >
> > + /* The CONCURRENTLY path does not write logical rewrite mappings. */
> >
> > IMO it makes no sense to rewrite the logical mappings as long as REPACK
> > (CONCURRENTLY) changes visibility information (i.e. it's MVCC-unsafe). Once we
> > implement the MVCC-safety, we should not remove this check unless we implement
> > the rewriting of the mappings for user catalog tables - that might also be
> > worth mentioning in the comment.
> >
> > So far, I'd consider the MVCC-unsafety the primary reason to prohibit REPACK
> > (CONCURRENTLY) (or anyother MVCC-unsafe command) on the user catalog tables,
> > because it can make the contents of those tables invisible to the output
> > plugin at some point.
>
> Thanks for pointing this out. I read the docs related to MVCC-safety
> of concurrent repack. I reworded the comment as you suggested. Feel
> free to suggest changes to it if any. Please find the attached v2
> patch.
Please find the attached v3 patch with a test added similar to other
restricted error cases. Sorry for the noise.
--
Bharath Rupireddy
Amazon Web Services: https://aws.amazon.com
Attachments:
v3-0001-Restrict-REPACK-CONCURRENTLY-on-user-catalog-tabl.patch (application/octet-stream, 5.1K) download
From 5fe70d4b3ca6d731bb9611500bb6975f9b8aa370 Mon Sep 17 00:00:00 2001
From: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Date: Tue, 1 Sep 2026 03:20:50 +0000
Subject: [PATCH v3] Restrict REPACK (CONCURRENTLY) on user catalog tables.
Commit 28d534e2ae0 added the CONCURRENTLY option to REPACK.
Unlike the default path, which rewrites the table through
rewriteheap.c, the concurrent path is not MVCC-safe: it changes
the visibility information of the tuples it rewrites.
A table declared with the user_catalog_table storage parameter is
read by an output plugin during logical decoding, using
historical snapshots. Changing that visibility information can
make the table's contents invisible to the plugin at some point,
silently breaking decoding.
check_concurrent_repack_requirements() already rejects system
catalogs but did not consider tables used as catalog tables.
Reject those too, the same way a table rewrite via ALTER TABLE
already does, and document the limitation. Once REPACK
(CONCURRENTLY) is made MVCC-safe, this check should stay unless
the rewrite mappings are also written for user catalog tables.
Backpatch to v19, where REPACK (CONCURRENTLY) was introduced.
Reported-by: Nathan Bossart <nathandbossart@gmail.com>
Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Reviewed-by: Antonin Houska <ah@cybertec.at>
Discussion: https://postgr.es/m/apBIFWzHYOaG0auN%40nathan
Backpatch-through: 19
---
contrib/test_decoding/expected/repack.out | 6 ++++++
contrib/test_decoding/sql/repack.sql | 5 +++++
doc/src/sgml/ref/repack.sgml | 8 ++++++++
src/backend/commands/repack.c | 15 +++++++++++++++
4 files changed, 34 insertions(+)
diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out
index 5ddc63238c5..6ed0af0f8ad 100644
--- a/contrib/test_decoding/expected/repack.out
+++ b/contrib/test_decoding/expected/repack.out
@@ -61,6 +61,12 @@ HINT: Consider running the command on individual partitions.
REPACK (CONCURRENTLY) pg_class;
ERROR: cannot execute REPACK (CONCURRENTLY) on relation "pg_class"
HINT: REPACK (CONCURRENTLY) is not supported for catalog relations.
+-- Doesn't support tables used as catalog tables
+CREATE TABLE repack_conc_user_catalog (i int) WITH (user_catalog_table = true);
+REPACK (CONCURRENTLY) repack_conc_user_catalog;
+ERROR: cannot execute REPACK (CONCURRENTLY) on relation "repack_conc_user_catalog"
+HINT: REPACK (CONCURRENTLY) is not supported for tables used as catalog tables.
+DROP TABLE repack_conc_user_catalog;
-- Doesn't support TOAST tables directly
CREATE TABLE repack_conc_toast (t text);
SELECT reltoastrelid::regclass AS toast_rel
diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql
index f461f5479f4..eb891009baf 100644
--- a/contrib/test_decoding/sql/repack.sql
+++ b/contrib/test_decoding/sql/repack.sql
@@ -42,6 +42,11 @@ REPACK (CONCURRENTLY) clstrpart;
-- Disallowed in catalogs
REPACK (CONCURRENTLY) pg_class;
+-- Doesn't support tables used as catalog tables
+CREATE TABLE repack_conc_user_catalog (i int) WITH (user_catalog_table = true);
+REPACK (CONCURRENTLY) repack_conc_user_catalog;
+DROP TABLE repack_conc_user_catalog;
+
-- Doesn't support TOAST tables directly
CREATE TABLE repack_conc_toast (t text);
SELECT reltoastrelid::regclass AS toast_rel
diff --git a/doc/src/sgml/ref/repack.sgml b/doc/src/sgml/ref/repack.sgml
index 0cb72b6b289..e2d5a34ba8b 100644
--- a/doc/src/sgml/ref/repack.sgml
+++ b/doc/src/sgml/ref/repack.sgml
@@ -285,6 +285,14 @@ REPACK [ ( <replaceable class="parameter">option</replaceable> [, ...] ) ] USING
</para>
</listitem>
+ <listitem>
+ <para>
+ The table is declared as a catalog table using the
+ <link linkend="reloption-user-catalog-table"><literal>user_catalog_table</literal></link>
+ storage parameter.
+ </para>
+ </listitem>
+
<listitem>
<para>
<command>REPACK</command> is executed inside a transaction block.
diff --git a/src/backend/commands/repack.c b/src/backend/commands/repack.c
index 477c86b2ba6..3da61437580 100644
--- a/src/backend/commands/repack.c
+++ b/src/backend/commands/repack.c
@@ -886,6 +886,21 @@ check_concurrent_repack_requirements(Relation rel, Oid *ident_idx_p)
errhint("%s is not supported for catalog relations.",
"REPACK (CONCURRENTLY)"));
+ /*
+ * Concurrent repack is not MVCC-safe, i.e. it changes visibility
+ * information, which can make the contents invisible to the output
+ * plugin. Once it is made MVCC-safe, the logical rewrite mappings must
+ * also be written for user catalog tables before this check can be
+ * removed.
+ */
+ if (RelationIsUsedAsCatalogTable(rel))
+ ereport(ERROR,
+ errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot execute %s on relation \"%s\"",
+ "REPACK (CONCURRENTLY)", RelationGetRelationName(rel)),
+ errhint("%s is not supported for tables used as catalog tables.",
+ "REPACK (CONCURRENTLY)"));
+
/*
* reorderbuffer.c does not seem to handle processing of TOAST relation
* alone.
--
2.47.3
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table
2026-08-27 14:22 REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Nathan Bossart <nathandbossart@gmail.com>
2026-08-27 22:46 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-08-29 11:23 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Antonin Houska <ah@cybertec.at>
2026-08-29 15:34 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-09-01 03:35 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
@ 2026-09-04 18:02 ` Masahiko Sawada <sawada.mshk@gmail.com>
2026-09-04 19:59 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-09-08 12:47 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Alvaro Herrera <alvherre@kurilemu.de>
0 siblings, 2 replies; 14+ messages in thread
From: Masahiko Sawada @ 2026-09-04 18:02 UTC (permalink / raw)
To: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>; +Cc: Antonin Houska <ah@cybertec.at>; Nathan Bossart <nathandbossart@gmail.com>; pgsql-hackers; alvherre@kurilemu.de
On Mon, Aug 31, 2026 at 8:35 PM Bharath Rupireddy
<bharath.rupireddyforpostgres@gmail.com> wrote:
>
> Hi,
>
> On Sat, Aug 29, 2026 at 8:34 AM Bharath Rupireddy
> <bharath.rupireddyforpostgres@gmail.com> wrote:
> >
> > Hi,
> >
> > On Sat, Aug 29, 2026 at 4:23 AM Antonin Houska <ah@cybertec.at> wrote:
> > >
> > > Thanks! I'm just thinking about this comment:
> > >
> > > + /* The CONCURRENTLY path does not write logical rewrite mappings. */
> > >
> > > IMO it makes no sense to rewrite the logical mappings as long as REPACK
> > > (CONCURRENTLY) changes visibility information (i.e. it's MVCC-unsafe). Once we
> > > implement the MVCC-safety, we should not remove this check unless we implement
> > > the rewriting of the mappings for user catalog tables - that might also be
> > > worth mentioning in the comment.
> > >
> > > So far, I'd consider the MVCC-unsafety the primary reason to prohibit REPACK
> > > (CONCURRENTLY) (or anyother MVCC-unsafe command) on the user catalog tables,
> > > because it can make the contents of those tables invisible to the output
> > > plugin at some point.
> >
> > Thanks for pointing this out. I read the docs related to MVCC-safety
> > of concurrent repack. I reworded the comment as you suggested. Feel
> > free to suggest changes to it if any. Please find the attached v2
> > patch.
>
> Please find the attached v3 patch with a test added similar to other
> restricted error cases. Sorry for the noise.
I reviewed the patch. It's simple and I agree to add a check for user
catalog tables. I've slightly rephrased the comment in
check_concurrent_repack_requirements() to clarify the reason why
REPACK (CONCURRENTLY) doesn't support user catalog tables while it
does for normal tables even though it's a MVCC-unsafe operation. Also
updated the commit message as well. Please review it.
Regards,
--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com
Attachments:
v4-0001-Restrict-REPACK-CONCURRENTLY-on-user-catalog-tabl.patch (text/x-patch, 4.6K) download
From f54f13e29b56fde249c96ffeb3d5044239f6927c Mon Sep 17 00:00:00 2001
From: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Date: Tue, 1 Sep 2026 03:20:50 +0000
Subject: [PATCH v4] Restrict REPACK (CONCURRENTLY) on user catalog tables.
REPACK (CONCURRENTLY) is not an MVCC-safe operation; it doesn't
preserve the visibility information, which logical decoding needs
because it reads user catalog tables under a historic snapshot.
Disallow REPACK (CONCURRENTLY) on user catalog tables. Removing this
check requires making it MVCC-safe and logical rewrite mappings.
Backpatch to v19, where REPACK (CONCURRENTLY) was introduced.
Reported-by: Nathan Bossart <nathandbossart@gmail.com>
Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Reviewed-by: Antonin Houska <ah@cybertec.at>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Discussion: https://postgr.es/m/apBIFWzHYOaG0auN%40nathan
Backpatch-through: 19
---
contrib/test_decoding/expected/repack.out | 6 ++++++
contrib/test_decoding/sql/repack.sql | 5 +++++
doc/src/sgml/ref/repack.sgml | 8 ++++++++
src/backend/commands/repack.c | 14 ++++++++++++++
4 files changed, 33 insertions(+)
diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out
index 5ddc63238c5..6ed0af0f8ad 100644
--- a/contrib/test_decoding/expected/repack.out
+++ b/contrib/test_decoding/expected/repack.out
@@ -61,6 +61,12 @@ HINT: Consider running the command on individual partitions.
REPACK (CONCURRENTLY) pg_class;
ERROR: cannot execute REPACK (CONCURRENTLY) on relation "pg_class"
HINT: REPACK (CONCURRENTLY) is not supported for catalog relations.
+-- Doesn't support tables used as catalog tables
+CREATE TABLE repack_conc_user_catalog (i int) WITH (user_catalog_table = true);
+REPACK (CONCURRENTLY) repack_conc_user_catalog;
+ERROR: cannot execute REPACK (CONCURRENTLY) on relation "repack_conc_user_catalog"
+HINT: REPACK (CONCURRENTLY) is not supported for tables used as catalog tables.
+DROP TABLE repack_conc_user_catalog;
-- Doesn't support TOAST tables directly
CREATE TABLE repack_conc_toast (t text);
SELECT reltoastrelid::regclass AS toast_rel
diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql
index f461f5479f4..eb891009baf 100644
--- a/contrib/test_decoding/sql/repack.sql
+++ b/contrib/test_decoding/sql/repack.sql
@@ -42,6 +42,11 @@ REPACK (CONCURRENTLY) clstrpart;
-- Disallowed in catalogs
REPACK (CONCURRENTLY) pg_class;
+-- Doesn't support tables used as catalog tables
+CREATE TABLE repack_conc_user_catalog (i int) WITH (user_catalog_table = true);
+REPACK (CONCURRENTLY) repack_conc_user_catalog;
+DROP TABLE repack_conc_user_catalog;
+
-- Doesn't support TOAST tables directly
CREATE TABLE repack_conc_toast (t text);
SELECT reltoastrelid::regclass AS toast_rel
diff --git a/doc/src/sgml/ref/repack.sgml b/doc/src/sgml/ref/repack.sgml
index 0cb72b6b289..e2d5a34ba8b 100644
--- a/doc/src/sgml/ref/repack.sgml
+++ b/doc/src/sgml/ref/repack.sgml
@@ -285,6 +285,14 @@ REPACK [ ( <replaceable class="parameter">option</replaceable> [, ...] ) ] USING
</para>
</listitem>
+ <listitem>
+ <para>
+ The table is declared as a catalog table using the
+ <link linkend="reloption-user-catalog-table"><literal>user_catalog_table</literal></link>
+ storage parameter.
+ </para>
+ </listitem>
+
<listitem>
<para>
<command>REPACK</command> is executed inside a transaction block.
diff --git a/src/backend/commands/repack.c b/src/backend/commands/repack.c
index 477c86b2ba6..b42fda303a2 100644
--- a/src/backend/commands/repack.c
+++ b/src/backend/commands/repack.c
@@ -886,6 +886,20 @@ check_concurrent_repack_requirements(Relation rel, Oid *ident_idx_p)
errhint("%s is not supported for catalog relations.",
"REPACK (CONCURRENTLY)"));
+ /*
+ * REPACK (CONCURRENTLY) is not MVCC-safe; it doesn't preserve visibility
+ * information, which logical decoding needs because it reads user catalog
+ * tables under a historic snapshot. Removing this check requires making
+ * it MVCC-safe and logical rewrite mappings.
+ */
+ if (RelationIsUsedAsCatalogTable(rel))
+ ereport(ERROR,
+ errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot execute %s on relation \"%s\"",
+ "REPACK (CONCURRENTLY)", RelationGetRelationName(rel)),
+ errhint("%s is not supported for tables used as catalog tables.",
+ "REPACK (CONCURRENTLY)"));
+
/*
* reorderbuffer.c does not seem to handle processing of TOAST relation
* alone.
--
2.55.0
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table
2026-08-27 14:22 REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Nathan Bossart <nathandbossart@gmail.com>
2026-08-27 22:46 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-08-29 11:23 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Antonin Houska <ah@cybertec.at>
2026-08-29 15:34 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-09-01 03:35 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-09-04 18:02 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Masahiko Sawada <sawada.mshk@gmail.com>
@ 2026-09-04 19:59 ` Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
1 sibling, 0 replies; 14+ messages in thread
From: Bharath Rupireddy @ 2026-09-04 19:59 UTC (permalink / raw)
To: Masahiko Sawada <sawada.mshk@gmail.com>; +Cc: Antonin Houska <ah@cybertec.at>; Nathan Bossart <nathandbossart@gmail.com>; pgsql-hackers; alvherre@kurilemu.de
Hi,
On Fri, Sep 4, 2026 at 11:02 AM Masahiko Sawada <sawada.mshk@gmail.com> wrote:
>
> I reviewed the patch. It's simple and I agree to add a check for user
> catalog tables. I've slightly rephrased the comment in
> check_concurrent_repack_requirements() to clarify the reason why
> REPACK (CONCURRENTLY) doesn't support user catalog tables while it
> does for normal tables even though it's a MVCC-unsafe operation. Also
> updated the commit message as well. Please review it.
Thanks for reviewing it. The v4 patch looks good to me. pgindent and
make check are happy.
A nit:
Code comment:
+ * tables under a historic snapshot. Removing this check requires making
+ * it MVCC-safe and logical rewrite mappings.
+ */
Commit message:
Disallow REPACK (CONCURRENTLY) on user catalog tables. Removing this
check requires making it MVCC-safe and logical rewrite mappings.
"Making it logical rewrite mappings" doesn't read correctly. How about
"Removing this check requires making it MVCC-safe and adding logical
rewrite mapping support" or such?
--
Bharath Rupireddy
Amazon Web Services: https://aws.amazon.com
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table
2026-08-27 14:22 REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Nathan Bossart <nathandbossart@gmail.com>
2026-08-27 22:46 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-08-29 11:23 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Antonin Houska <ah@cybertec.at>
2026-08-29 15:34 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-09-01 03:35 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-09-04 18:02 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Masahiko Sawada <sawada.mshk@gmail.com>
@ 2026-09-08 12:47 ` Alvaro Herrera <alvherre@kurilemu.de>
2026-09-08 15:58 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-09-08 18:23 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Masahiko Sawada <sawada.mshk@gmail.com>
1 sibling, 2 replies; 14+ messages in thread
From: Alvaro Herrera @ 2026-09-08 12:47 UTC (permalink / raw)
To: Masahiko Sawada <sawada.mshk@gmail.com>; +Cc: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>; Antonin Houska <ah@cybertec.at>; Nathan Bossart <nathandbossart@gmail.com>; pgsql-hackers
Hello,
On 2026-Sep-04, Masahiko Sawada wrote:
> I reviewed the patch. It's simple and I agree to add a check for user
> catalog tables. I've slightly rephrased the comment in
> check_concurrent_repack_requirements() to clarify the reason why
> REPACK (CONCURRENTLY) doesn't support user catalog tables while it
> does for normal tables even though it's a MVCC-unsafe operation. Also
> updated the commit message as well. Please review it.
Thanks, I gave this a look and I think it's okay. I'm not sure about
the exact wording of the error message though,
> + ereport(ERROR,
> + errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
> + errmsg("cannot execute %s on relation \"%s\"",
> + "REPACK (CONCURRENTLY)", RelationGetRelationName(rel)),
> + errhint("%s is not supported for tables used as catalog tables.",
> + "REPACK (CONCURRENTLY)"));
ERROR: cannot execute REPACK (CONCURRENTLY) on relation "foobar"
HINT: REPACK (CONCURRENTLY) is not supported for tables used as catalog tables.
I think the HINT should really be DETAIL, and I'm not sure we need to
mention the command again there. On the other hand, I'm not really
happy with the term "tables used as catalog tables". In the
documentation we use the term "user provided catalog tables" or simply
"user catalog tables" (see <sect2 id="logicaldecoding-capabilities">).
So how about something like this?
ERROR: cannot execute REPACK (CONCURRENTLY) on relation "foobar"
DETAIL: This operation is not supported for user catalog tables.
Would you push this patch, or do you want me to?
Thanks!
--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table
2026-08-27 14:22 REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Nathan Bossart <nathandbossart@gmail.com>
2026-08-27 22:46 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-08-29 11:23 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Antonin Houska <ah@cybertec.at>
2026-08-29 15:34 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-09-01 03:35 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-09-04 18:02 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Masahiko Sawada <sawada.mshk@gmail.com>
2026-09-08 12:47 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Alvaro Herrera <alvherre@kurilemu.de>
@ 2026-09-08 15:58 ` Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
1 sibling, 0 replies; 14+ messages in thread
From: Bharath Rupireddy @ 2026-09-08 15:58 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@kurilemu.de>; +Cc: Masahiko Sawada <sawada.mshk@gmail.com>; Antonin Houska <ah@cybertec.at>; Nathan Bossart <nathandbossart@gmail.com>; pgsql-hackers
Hi,
On Tue, Sep 8, 2026 at 5:47 AM Alvaro Herrera <alvherre@kurilemu.de> wrote:
>
> Thanks, I gave this a look and I think it's okay. I'm not sure about
> the exact wording of the error message though,
Thanks for reviewing it.
> > + ereport(ERROR,
> > + errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
> > + errmsg("cannot execute %s on relation \"%s\"",
> > + "REPACK (CONCURRENTLY)", RelationGetRelationName(rel)),
> > + errhint("%s is not supported for tables used as catalog tables.",
> > + "REPACK (CONCURRENTLY)"));
>
> ERROR: cannot execute REPACK (CONCURRENTLY) on relation "foobar"
> HINT: REPACK (CONCURRENTLY) is not supported for tables used as catalog tables.
>
> I think the HINT should really be DETAIL, and I'm not sure we need to
> mention the command again there.
>
> On the other hand, I'm not really
> happy with the term "tables used as catalog tables". In the
> documentation we use the term "user provided catalog tables" or simply
> "user catalog tables" (see <sect2 id="logicaldecoding-capabilities">).
> So how about something like this?
>
> ERROR: cannot execute REPACK (CONCURRENTLY) on relation "foobar"
> DETAIL: This operation is not supported for user catalog tables.
I agree that this is not a hint message. If we ever say something like
"Please do something to get repack to work on user catalog tables,"
that would be a hint, but here we are giving more details about the
error itself. And "user catalog tables" looks good to me too (although
existing error messages around RelationIsUsedAsCatalogTable() uses
table used as a catalog table, with "system catalogs" meaning the
core-provided ones. Also, the proposed wording looks consistent with
errdetail_relkind_not_supported(). So, I used that in the attached
0001.
I agree that this is not a hint message. If we ever say something like
"Please do something to get repack to work on user catalog tables,"
that would be a hint, but here we are giving more details about the
error itself.
"User catalog tables" looks good to me too, although the existing
error messages around RelationIsUsedAsCatalogTable() use "table used
as a catalog table," with "system catalogs" meaning the core-provided
ones.
The proposed wording also looks consistent with
errdetail_relkind_not_supported(). So, I used that in the attached
0001.
That said, I also think we can keep the messaging style consistent
within this function. So, in the attached 0002, I changed the existing
error messages for system catalogs, TOAST tables, non-permanent tables
etc. to use detail messages instead of hints, with consistent wording.
Please find the attached v5 patches.
--
Bharath Rupireddy
Amazon Web Services: https://aws.amazon.com
Attachments: download all (2 files, .tar.gz)
v5-0001-Restrict-REPACK-CONCURRENTLY-on-user-catalog-tabl.patch (application/octet-stream, 4.6K) download
From 0504406d44fb810db1bd1a927d4a34ddd07f2876 Mon Sep 17 00:00:00 2001
From: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Date: Tue, 8 Sep 2026 15:47:01 +0000
Subject: [PATCH v5 1/2] Restrict REPACK (CONCURRENTLY) on user catalog tables.
REPACK (CONCURRENTLY) is not an MVCC-safe operation; it doesn't
preserve the visibility information, which logical decoding needs
because it reads user catalog tables under a historic snapshot.
Disallow REPACK (CONCURRENTLY) on user catalog tables. Removing this
check requires making it MVCC-safe and logical rewrite mappings.
Backpatch to v19, where REPACK (CONCURRENTLY) was introduced.
Reported-by: Nathan Bossart <nathandbossart@gmail.com>
Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Reviewed-by: Antonin Houska <ah@cybertec.at>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Reviewed-by: Alvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/apBIFWzHYOaG0auN%40nathan
Backpatch-through: 19
---
contrib/test_decoding/expected/repack.out | 6 ++++++
contrib/test_decoding/sql/repack.sql | 5 +++++
doc/src/sgml/ref/repack.sgml | 8 ++++++++
src/backend/commands/repack.c | 13 +++++++++++++
4 files changed, 32 insertions(+)
diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out
index 5ddc63238c5..ce2cadfa222 100644
--- a/contrib/test_decoding/expected/repack.out
+++ b/contrib/test_decoding/expected/repack.out
@@ -61,6 +61,12 @@ HINT: Consider running the command on individual partitions.
REPACK (CONCURRENTLY) pg_class;
ERROR: cannot execute REPACK (CONCURRENTLY) on relation "pg_class"
HINT: REPACK (CONCURRENTLY) is not supported for catalog relations.
+-- Doesn't support tables used as catalog tables
+CREATE TABLE repack_conc_user_catalog (i int) WITH (user_catalog_table = true);
+REPACK (CONCURRENTLY) repack_conc_user_catalog;
+ERROR: cannot execute REPACK (CONCURRENTLY) on relation "repack_conc_user_catalog"
+DETAIL: This operation is not supported for user catalog tables.
+DROP TABLE repack_conc_user_catalog;
-- Doesn't support TOAST tables directly
CREATE TABLE repack_conc_toast (t text);
SELECT reltoastrelid::regclass AS toast_rel
diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql
index f461f5479f4..eb891009baf 100644
--- a/contrib/test_decoding/sql/repack.sql
+++ b/contrib/test_decoding/sql/repack.sql
@@ -42,6 +42,11 @@ REPACK (CONCURRENTLY) clstrpart;
-- Disallowed in catalogs
REPACK (CONCURRENTLY) pg_class;
+-- Doesn't support tables used as catalog tables
+CREATE TABLE repack_conc_user_catalog (i int) WITH (user_catalog_table = true);
+REPACK (CONCURRENTLY) repack_conc_user_catalog;
+DROP TABLE repack_conc_user_catalog;
+
-- Doesn't support TOAST tables directly
CREATE TABLE repack_conc_toast (t text);
SELECT reltoastrelid::regclass AS toast_rel
diff --git a/doc/src/sgml/ref/repack.sgml b/doc/src/sgml/ref/repack.sgml
index d9c7c9e6b95..d40740738f1 100644
--- a/doc/src/sgml/ref/repack.sgml
+++ b/doc/src/sgml/ref/repack.sgml
@@ -285,6 +285,14 @@ REPACK [ ( <replaceable class="parameter">option</replaceable> [, ...] ) ] USING
</para>
</listitem>
+ <listitem>
+ <para>
+ The table is declared as a catalog table using the
+ <link linkend="reloption-user-catalog-table"><literal>user_catalog_table</literal></link>
+ storage parameter.
+ </para>
+ </listitem>
+
<listitem>
<para>
<command>REPACK</command> is executed inside a transaction block.
diff --git a/src/backend/commands/repack.c b/src/backend/commands/repack.c
index 89aa038d23d..086bef834ec 100644
--- a/src/backend/commands/repack.c
+++ b/src/backend/commands/repack.c
@@ -897,6 +897,19 @@ check_concurrent_repack_requirements(Relation rel, Oid *ident_idx_p)
errhint("%s is not supported for catalog relations.",
"REPACK (CONCURRENTLY)"));
+ /*
+ * REPACK (CONCURRENTLY) is not MVCC-safe; it doesn't preserve visibility
+ * information, which logical decoding needs because it reads user catalog
+ * tables under a historic snapshot. Removing this check requires making
+ * it MVCC-safe and logical rewrite mappings.
+ */
+ if (RelationIsUsedAsCatalogTable(rel))
+ ereport(ERROR,
+ errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot execute %s on relation \"%s\"",
+ "REPACK (CONCURRENTLY)", RelationGetRelationName(rel)),
+ errdetail("This operation is not supported for user catalog tables."));
+
/*
* reorderbuffer.c does not seem to handle processing of TOAST relation
* alone.
--
2.47.3
v5-0002-Use-detail-messages-consistently-in-REPACK-CONCUR.patch (application/octet-stream, 7.9K) download
From 4bc86d92da636de9d9f9a4acac40fd15ac67d709 Mon Sep 17 00:00:00 2001
From: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Date: Tue, 8 Sep 2026 15:52:15 +0000
Subject: [PATCH v5 2/2] Use detail messages consistently in REPACK
(CONCURRENTLY) checks.
check_concurrent_repack_requirements() reported its restrictions
with a mix of hint and detail messages. Some messages that only
describe why the error happened (system catalogs, TOAST tables,
non-permanent relations, and the missing identity index) were
written as hints, and the detail messages repeated "REPACK
(CONCURRENTLY)", which the main error message already names.
Change these so each restriction is reported as a detail message
with consistent "This operation ..." wording, matching
errdetail_relkind_not_supported(). The only hint left is the
useful one that suggests ALTER TABLE ... REPLICA IDENTITY USING
INDEX.
Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Reviewed-by: Alvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/apBIFWzHYOaG0auN%40nathan
Backpatch-through: 19
---
contrib/test_decoding/expected/repack.out | 12 ++++++------
src/backend/commands/repack.c | 22 ++++++++--------------
2 files changed, 14 insertions(+), 20 deletions(-)
diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out
index ce2cadfa222..b85cd92aa1a 100644
--- a/contrib/test_decoding/expected/repack.out
+++ b/contrib/test_decoding/expected/repack.out
@@ -60,7 +60,7 @@ HINT: Consider running the command on individual partitions.
-- Disallowed in catalogs
REPACK (CONCURRENTLY) pg_class;
ERROR: cannot execute REPACK (CONCURRENTLY) on relation "pg_class"
-HINT: REPACK (CONCURRENTLY) is not supported for catalog relations.
+DETAIL: This operation is not supported for system catalogs.
-- Doesn't support tables used as catalog tables
CREATE TABLE repack_conc_user_catalog (i int) WITH (user_catalog_table = true);
REPACK (CONCURRENTLY) repack_conc_user_catalog;
@@ -80,30 +80,30 @@ DROP TABLE repack_conc_toast;
CREATE TEMP TABLE repack_conc_temp (i int PRIMARY KEY);
REPACK (CONCURRENTLY) repack_conc_temp;
ERROR: cannot execute REPACK (CONCURRENTLY) on relation "repack_conc_temp"
-HINT: REPACK (CONCURRENTLY) is only allowed for permanent relations.
+DETAIL: This operation is only supported for permanent relations.
DROP TABLE repack_conc_temp;
CREATE UNLOGGED TABLE repack_conc_unlogged (i int PRIMARY KEY);
REPACK (CONCURRENTLY) repack_conc_unlogged;
ERROR: cannot execute REPACK (CONCURRENTLY) on relation "repack_conc_unlogged"
-HINT: REPACK (CONCURRENTLY) is only allowed for permanent relations.
+DETAIL: This operation is only supported for permanent relations.
DROP TABLE repack_conc_unlogged;
-- Doesn't support tables with REPLICA IDENTITY NOTHING, even if they have a primary key
CREATE TABLE repack_conc_replident (i int PRIMARY KEY);
ALTER TABLE repack_conc_replident REPLICA IDENTITY NOTHING;
REPACK (CONCURRENTLY) repack_conc_replident;
ERROR: cannot execute REPACK (CONCURRENTLY) on relation "repack_conc_replident"
-DETAIL: REPACK (CONCURRENTLY) does not support tables with REPLICA IDENTITY NOTHING.
+DETAIL: This operation does not support tables with REPLICA IDENTITY NOTHING.
-- Doesn't support tables without a primary key or replica identity index
ALTER TABLE repack_conc_replident DROP CONSTRAINT repack_conc_replident_pkey;
ALTER TABLE repack_conc_replident REPLICA IDENTITY DEFAULT;
REPACK (CONCURRENTLY) repack_conc_replident;
ERROR: cannot execute REPACK (CONCURRENTLY) on relation "repack_conc_replident"
-HINT: Relation "repack_conc_replident" has no identity index.
+DETAIL: Relation "repack_conc_replident" has no identity index.
-- Doesn't support tables with deferrable primary keys
ALTER TABLE repack_conc_replident ADD PRIMARY KEY (i) DEFERRABLE;
REPACK (CONCURRENTLY) repack_conc_replident;
ERROR: cannot execute REPACK (CONCURRENTLY) on relation "repack_conc_replident"
-DETAIL: REPACK (CONCURRENTLY) does not support deferrable primary keys.
+DETAIL: This operation does not support deferrable primary keys.
HINT: Use ALTER TABLE ... REPLICA IDENTITY USING INDEX to designate another index as replica identity.
-- clean up
DROP TABLE repack_conc_replident, clstrpart;
diff --git a/src/backend/commands/repack.c b/src/backend/commands/repack.c
index 086bef834ec..f6da2b1085d 100644
--- a/src/backend/commands/repack.c
+++ b/src/backend/commands/repack.c
@@ -885,8 +885,7 @@ check_concurrent_repack_requirements(Relation rel, Oid *ident_idx_p)
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("cannot execute %s in this configuration",
"REPACK (CONCURRENTLY)"),
- errdetail("%s requires \"wal_level\" to be set to \"replica\" or higher.",
- "REPACK (CONCURRENTLY)"));
+ errdetail("This operation requires \"wal_level\" to be set to \"replica\" or higher."));
/* Data changes in system relations are not logically decoded. */
if (IsCatalogRelation(rel))
@@ -894,8 +893,7 @@ check_concurrent_repack_requirements(Relation rel, Oid *ident_idx_p)
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot execute %s on relation \"%s\"",
"REPACK (CONCURRENTLY)", RelationGetRelationName(rel)),
- errhint("%s is not supported for catalog relations.",
- "REPACK (CONCURRENTLY)"));
+ errdetail("This operation is not supported for system catalogs."));
/*
* REPACK (CONCURRENTLY) is not MVCC-safe; it doesn't preserve visibility
@@ -919,8 +917,7 @@ check_concurrent_repack_requirements(Relation rel, Oid *ident_idx_p)
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot execute %s on relation \"%s\"",
"REPACK (CONCURRENTLY)", RelationGetRelationName(rel)),
- errhint("%s is not supported for TOAST relations.",
- "REPACK (CONCURRENTLY)"));
+ errdetail("This operation is not supported for TOAST tables."));
relpersistence = rel->rd_rel->relpersistence;
if (relpersistence != RELPERSISTENCE_PERMANENT)
@@ -928,8 +925,7 @@ check_concurrent_repack_requirements(Relation rel, Oid *ident_idx_p)
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("cannot execute %s on relation \"%s\"",
"REPACK (CONCURRENTLY)", RelationGetRelationName(rel)),
- errhint("%s is only allowed for permanent relations.",
- "REPACK (CONCURRENTLY)"));
+ errdetail("This operation is only supported for permanent relations."));
/*
* With NOTHING, WAL does not contain the old tuple; FULL is not yet
@@ -942,8 +938,7 @@ check_concurrent_repack_requirements(Relation rel, Oid *ident_idx_p)
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("cannot execute %s on relation \"%s\"",
"REPACK (CONCURRENTLY)", RelationGetRelationName(rel)),
- errdetail("%s does not support tables with %s.",
- "REPACK (CONCURRENTLY)",
+ errdetail("This operation does not support tables with %s.",
replident == REPLICA_IDENTITY_NOTHING ?
"REPLICA IDENTITY NOTHING" : "REPLICA IDENTITY FULL"));
@@ -964,16 +959,15 @@ check_concurrent_repack_requirements(Relation rel, Oid *ident_idx_p)
errmsg("cannot execute %s on relation \"%s\"",
"REPACK (CONCURRENTLY)",
RelationGetRelationName(rel)),
- errdetail("%s does not support deferrable primary keys.",
- "REPACK (CONCURRENTLY)"),
+ errdetail("This operation does not support deferrable primary keys."),
errhint("Use ALTER TABLE ... REPLICA IDENTITY USING INDEX to designate another index as replica identity."));
ereport(ERROR,
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("cannot execute %s on relation \"%s\"",
"REPACK (CONCURRENTLY)", RelationGetRelationName(rel)),
- errhint("Relation \"%s\" has no identity index.",
- RelationGetRelationName(rel)));
+ errdetail("Relation \"%s\" has no identity index.",
+ RelationGetRelationName(rel)));
}
*ident_idx_p = ident_idx;
--
2.47.3
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table
2026-08-27 14:22 REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Nathan Bossart <nathandbossart@gmail.com>
2026-08-27 22:46 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-08-29 11:23 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Antonin Houska <ah@cybertec.at>
2026-08-29 15:34 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-09-01 03:35 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-09-04 18:02 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Masahiko Sawada <sawada.mshk@gmail.com>
2026-09-08 12:47 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Alvaro Herrera <alvherre@kurilemu.de>
@ 2026-09-08 18:23 ` Masahiko Sawada <sawada.mshk@gmail.com>
2026-09-08 18:57 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Alvaro Herrera <alvherre@kurilemu.de>
1 sibling, 1 reply; 14+ messages in thread
From: Masahiko Sawada @ 2026-09-08 18:23 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@kurilemu.de>; +Cc: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>; Antonin Houska <ah@cybertec.at>; Nathan Bossart <nathandbossart@gmail.com>; pgsql-hackers
On Tue, Sep 8, 2026 at 5:47 AM Alvaro Herrera <alvherre@kurilemu.de> wrote:
>
> Hello,
>
> On 2026-Sep-04, Masahiko Sawada wrote:
>
> > I reviewed the patch. It's simple and I agree to add a check for user
> > catalog tables. I've slightly rephrased the comment in
> > check_concurrent_repack_requirements() to clarify the reason why
> > REPACK (CONCURRENTLY) doesn't support user catalog tables while it
> > does for normal tables even though it's a MVCC-unsafe operation. Also
> > updated the commit message as well. Please review it.
>
> Thanks, I gave this a look and I think it's okay. I'm not sure about
> the exact wording of the error message though,
>
> > + ereport(ERROR,
> > + errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
> > + errmsg("cannot execute %s on relation \"%s\"",
> > + "REPACK (CONCURRENTLY)", RelationGetRelationName(rel)),
> > + errhint("%s is not supported for tables used as catalog tables.",
> > + "REPACK (CONCURRENTLY)"));
>
> ERROR: cannot execute REPACK (CONCURRENTLY) on relation "foobar"
> HINT: REPACK (CONCURRENTLY) is not supported for tables used as catalog tables.
>
> I think the HINT should really be DETAIL, and I'm not sure we need to
> mention the command again there. On the other hand, I'm not really
> happy with the term "tables used as catalog tables". In the
> documentation we use the term "user provided catalog tables" or simply
> "user catalog tables" (see <sect2 id="logicaldecoding-capabilities">).
> So how about something like this?
>
> ERROR: cannot execute REPACK (CONCURRENTLY) on relation "foobar"
> DETAIL: This operation is not supported for user catalog tables.
Looks good to me.
> Would you push this patch, or do you want me to?
I can take it if you are okay, as it's a trivial fix.
Regards,
--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table
2026-08-27 14:22 REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Nathan Bossart <nathandbossart@gmail.com>
2026-08-27 22:46 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-08-29 11:23 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Antonin Houska <ah@cybertec.at>
2026-08-29 15:34 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-09-01 03:35 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-09-04 18:02 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Masahiko Sawada <sawada.mshk@gmail.com>
2026-09-08 12:47 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Alvaro Herrera <alvherre@kurilemu.de>
2026-09-08 18:23 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Masahiko Sawada <sawada.mshk@gmail.com>
@ 2026-09-08 18:57 ` Alvaro Herrera <alvherre@kurilemu.de>
2026-09-08 20:08 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Masahiko Sawada <sawada.mshk@gmail.com>
0 siblings, 1 reply; 14+ messages in thread
From: Alvaro Herrera @ 2026-09-08 18:57 UTC (permalink / raw)
To: Masahiko Sawada <sawada.mshk@gmail.com>; +Cc: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>; Antonin Houska <ah@cybertec.at>; Nathan Bossart <nathandbossart@gmail.com>; pgsql-hackers
On 2026-Sep-08, Masahiko Sawada wrote:
> On Tue, Sep 8, 2026 at 5:47 AM Alvaro Herrera <alvherre@kurilemu.de> wrote:
> > Would you push this patch, or do you want me to?
>
> I can take it if you are okay, as it's a trivial fix.
Yeah, sounds good, thanks.
--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/
"No nos atrevemos a muchas cosas porque son difíciles,
pero son difíciles porque no nos atrevemos a hacerlas" (Séneca)
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table
2026-08-27 14:22 REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Nathan Bossart <nathandbossart@gmail.com>
2026-08-27 22:46 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-08-29 11:23 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Antonin Houska <ah@cybertec.at>
2026-08-29 15:34 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-09-01 03:35 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-09-04 18:02 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Masahiko Sawada <sawada.mshk@gmail.com>
2026-09-08 12:47 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Alvaro Herrera <alvherre@kurilemu.de>
2026-09-08 18:23 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Masahiko Sawada <sawada.mshk@gmail.com>
2026-09-08 18:57 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Alvaro Herrera <alvherre@kurilemu.de>
@ 2026-09-08 20:08 ` Masahiko Sawada <sawada.mshk@gmail.com>
2026-09-09 17:28 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
0 siblings, 1 reply; 14+ messages in thread
From: Masahiko Sawada @ 2026-09-08 20:08 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@kurilemu.de>; +Cc: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>; Antonin Houska <ah@cybertec.at>; Nathan Bossart <nathandbossart@gmail.com>; pgsql-hackers
On Tue, Sep 8, 2026 at 11:57 AM Alvaro Herrera <alvherre@kurilemu.de> wrote:
>
> On 2026-Sep-08, Masahiko Sawada wrote:
>
> > On Tue, Sep 8, 2026 at 5:47 AM Alvaro Herrera <alvherre@kurilemu.de> wrote:
>
> > > Would you push this patch, or do you want me to?
> >
> > I can take it if you are okay, as it's a trivial fix.
>
> Yeah, sounds good, thanks.
Pushed.
Regards,
--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table
2026-08-27 14:22 REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Nathan Bossart <nathandbossart@gmail.com>
2026-08-27 22:46 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-08-29 11:23 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Antonin Houska <ah@cybertec.at>
2026-08-29 15:34 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-09-01 03:35 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-09-04 18:02 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Masahiko Sawada <sawada.mshk@gmail.com>
2026-09-08 12:47 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Alvaro Herrera <alvherre@kurilemu.de>
2026-09-08 18:23 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Masahiko Sawada <sawada.mshk@gmail.com>
2026-09-08 18:57 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Alvaro Herrera <alvherre@kurilemu.de>
2026-09-08 20:08 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Masahiko Sawada <sawada.mshk@gmail.com>
@ 2026-09-09 17:28 ` Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-09-09 20:47 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Masahiko Sawada <sawada.mshk@gmail.com>
0 siblings, 1 reply; 14+ messages in thread
From: Bharath Rupireddy @ 2026-09-09 17:28 UTC (permalink / raw)
To: Masahiko Sawada <sawada.mshk@gmail.com>; +Cc: Alvaro Herrera <alvherre@kurilemu.de>; Antonin Houska <ah@cybertec.at>; Nathan Bossart <nathandbossart@gmail.com>; pgsql-hackers
Hi,
On Tue, Sep 8, 2026 at 1:09 PM Masahiko Sawada <sawada.mshk@gmail.com> wrote:
>
> Pushed.
Thanks for taking care of this. Please find another remaining patch
rebased to use detail instead of hints and reword the messages
consistently in REPACK (CONCURRENTLY) checks.
--
Bharath Rupireddy
Amazon Web Services: https://aws.amazon.com
Attachments:
v6-0001-Use-detail-messages-consistently-in-REPACK-CONCUR.patch (application/octet-stream, 7.9K) download
From 6d63df0e3e239f4bf62b3228633720f16f5ccd21 Mon Sep 17 00:00:00 2001
From: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Date: Tue, 8 Sep 2026 15:52:15 +0000
Subject: [PATCH v6] Use detail messages consistently in REPACK (CONCURRENTLY)
checks.
check_concurrent_repack_requirements() reported its restrictions
with a mix of hint and detail messages. Some messages that only
describe why the error happened (system catalogs, TOAST tables,
non-permanent relations, and the missing identity index) were
written as hints, and the detail messages repeated "REPACK
(CONCURRENTLY)", which the main error message already names.
Change these so each restriction is reported as a detail message
with consistent "This operation ..." wording, matching
errdetail_relkind_not_supported(). The only hint left is the
useful one that suggests ALTER TABLE ... REPLICA IDENTITY USING
INDEX.
Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Reviewed-by: Alvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/apBIFWzHYOaG0auN%40nathan
Backpatch-through: 19
---
contrib/test_decoding/expected/repack.out | 12 ++++++------
src/backend/commands/repack.c | 22 ++++++++--------------
2 files changed, 14 insertions(+), 20 deletions(-)
diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out
index 2dd3891b869..ac5473137d1 100644
--- a/contrib/test_decoding/expected/repack.out
+++ b/contrib/test_decoding/expected/repack.out
@@ -60,7 +60,7 @@ HINT: Consider running the command on individual partitions.
-- Disallowed in catalogs
REPACK (CONCURRENTLY) pg_class;
ERROR: cannot execute REPACK (CONCURRENTLY) on relation "pg_class"
-HINT: REPACK (CONCURRENTLY) is not supported for catalog relations.
+DETAIL: This operation is not supported for system catalogs.
-- Doesn't support tables used as catalog tables
CREATE TABLE repack_conc_user_catalog (i int) WITH (user_catalog_table = true);
REPACK (CONCURRENTLY) repack_conc_user_catalog;
@@ -80,12 +80,12 @@ DROP TABLE repack_conc_toast;
CREATE TEMP TABLE repack_conc_temp (i int PRIMARY KEY);
REPACK (CONCURRENTLY) repack_conc_temp;
ERROR: cannot execute REPACK (CONCURRENTLY) on relation "repack_conc_temp"
-HINT: REPACK (CONCURRENTLY) is only allowed for permanent relations.
+DETAIL: This operation is only supported for permanent relations.
DROP TABLE repack_conc_temp;
CREATE UNLOGGED TABLE repack_conc_unlogged (i int PRIMARY KEY);
REPACK (CONCURRENTLY) repack_conc_unlogged;
ERROR: cannot execute REPACK (CONCURRENTLY) on relation "repack_conc_unlogged"
-HINT: REPACK (CONCURRENTLY) is only allowed for permanent relations.
+DETAIL: This operation is only supported for permanent relations.
DROP TABLE repack_conc_unlogged;
-- Doesn't support materialized views
CREATE MATERIALIZED VIEW repack_conc_matview AS SELECT 1 AS i;
@@ -98,18 +98,18 @@ CREATE TABLE repack_conc_replident (i int PRIMARY KEY);
ALTER TABLE repack_conc_replident REPLICA IDENTITY NOTHING;
REPACK (CONCURRENTLY) repack_conc_replident;
ERROR: cannot execute REPACK (CONCURRENTLY) on relation "repack_conc_replident"
-DETAIL: REPACK (CONCURRENTLY) does not support tables with REPLICA IDENTITY NOTHING.
+DETAIL: This operation does not support tables with REPLICA IDENTITY NOTHING.
-- Doesn't support tables without a primary key or replica identity index
ALTER TABLE repack_conc_replident DROP CONSTRAINT repack_conc_replident_pkey;
ALTER TABLE repack_conc_replident REPLICA IDENTITY DEFAULT;
REPACK (CONCURRENTLY) repack_conc_replident;
ERROR: cannot execute REPACK (CONCURRENTLY) on relation "repack_conc_replident"
-HINT: Relation "repack_conc_replident" has no identity index.
+DETAIL: Relation "repack_conc_replident" has no identity index.
-- Doesn't support tables with deferrable primary keys
ALTER TABLE repack_conc_replident ADD PRIMARY KEY (i) DEFERRABLE;
REPACK (CONCURRENTLY) repack_conc_replident;
ERROR: cannot execute REPACK (CONCURRENTLY) on relation "repack_conc_replident"
-DETAIL: REPACK (CONCURRENTLY) does not support deferrable primary keys.
+DETAIL: This operation does not support deferrable primary keys.
HINT: Use ALTER TABLE ... REPLICA IDENTITY USING INDEX to designate another index as replica identity.
-- clean up
DROP TABLE repack_conc_replident, clstrpart;
diff --git a/src/backend/commands/repack.c b/src/backend/commands/repack.c
index 4521ccd036f..0533217968e 100644
--- a/src/backend/commands/repack.c
+++ b/src/backend/commands/repack.c
@@ -885,8 +885,7 @@ check_concurrent_repack_requirements(Relation rel, Oid *ident_idx_p)
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("cannot execute %s in this configuration",
"REPACK (CONCURRENTLY)"),
- errdetail("%s requires \"wal_level\" to be set to \"replica\" or higher.",
- "REPACK (CONCURRENTLY)"));
+ errdetail("This operation requires \"wal_level\" to be set to \"replica\" or higher."));
/*
* A table AM that doesn't support logical decoding would cause REPACK
@@ -908,8 +907,7 @@ check_concurrent_repack_requirements(Relation rel, Oid *ident_idx_p)
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot execute %s on relation \"%s\"",
"REPACK (CONCURRENTLY)", RelationGetRelationName(rel)),
- errhint("%s is not supported for catalog relations.",
- "REPACK (CONCURRENTLY)"));
+ errdetail("This operation is not supported for system catalogs."));
/*
* REPACK (CONCURRENTLY) is not MVCC-safe; it doesn't preserve visibility
@@ -933,8 +931,7 @@ check_concurrent_repack_requirements(Relation rel, Oid *ident_idx_p)
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot execute %s on relation \"%s\"",
"REPACK (CONCURRENTLY)", RelationGetRelationName(rel)),
- errhint("%s is not supported for TOAST relations.",
- "REPACK (CONCURRENTLY)"));
+ errdetail("This operation is not supported for TOAST tables."));
relpersistence = rel->rd_rel->relpersistence;
if (relpersistence != RELPERSISTENCE_PERMANENT)
@@ -942,8 +939,7 @@ check_concurrent_repack_requirements(Relation rel, Oid *ident_idx_p)
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("cannot execute %s on relation \"%s\"",
"REPACK (CONCURRENTLY)", RelationGetRelationName(rel)),
- errhint("%s is only allowed for permanent relations.",
- "REPACK (CONCURRENTLY)"));
+ errdetail("This operation is only supported for permanent relations."));
/* A materialized view produces no logically decoded changes. */
if (rel->rd_rel->relkind == RELKIND_MATVIEW)
@@ -964,8 +960,7 @@ check_concurrent_repack_requirements(Relation rel, Oid *ident_idx_p)
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("cannot execute %s on relation \"%s\"",
"REPACK (CONCURRENTLY)", RelationGetRelationName(rel)),
- errdetail("%s does not support tables with %s.",
- "REPACK (CONCURRENTLY)",
+ errdetail("This operation does not support tables with %s.",
replident == REPLICA_IDENTITY_NOTHING ?
"REPLICA IDENTITY NOTHING" : "REPLICA IDENTITY FULL"));
@@ -986,16 +981,15 @@ check_concurrent_repack_requirements(Relation rel, Oid *ident_idx_p)
errmsg("cannot execute %s on relation \"%s\"",
"REPACK (CONCURRENTLY)",
RelationGetRelationName(rel)),
- errdetail("%s does not support deferrable primary keys.",
- "REPACK (CONCURRENTLY)"),
+ errdetail("This operation does not support deferrable primary keys."),
errhint("Use ALTER TABLE ... REPLICA IDENTITY USING INDEX to designate another index as replica identity."));
ereport(ERROR,
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("cannot execute %s on relation \"%s\"",
"REPACK (CONCURRENTLY)", RelationGetRelationName(rel)),
- errhint("Relation \"%s\" has no identity index.",
- RelationGetRelationName(rel)));
+ errdetail("Relation \"%s\" has no identity index.",
+ RelationGetRelationName(rel)));
}
*ident_idx_p = ident_idx;
--
2.47.3
^ permalink raw reply [nested|flat] 14+ messages in thread
* Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table
2026-08-27 14:22 REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Nathan Bossart <nathandbossart@gmail.com>
2026-08-27 22:46 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-08-29 11:23 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Antonin Houska <ah@cybertec.at>
2026-08-29 15:34 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-09-01 03:35 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-09-04 18:02 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Masahiko Sawada <sawada.mshk@gmail.com>
2026-09-08 12:47 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Alvaro Herrera <alvherre@kurilemu.de>
2026-09-08 18:23 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Masahiko Sawada <sawada.mshk@gmail.com>
2026-09-08 18:57 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Alvaro Herrera <alvherre@kurilemu.de>
2026-09-08 20:08 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Masahiko Sawada <sawada.mshk@gmail.com>
2026-09-09 17:28 ` Re: REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
@ 2026-09-09 20:47 ` Masahiko Sawada <sawada.mshk@gmail.com>
0 siblings, 0 replies; 14+ messages in thread
From: Masahiko Sawada @ 2026-09-09 20:47 UTC (permalink / raw)
To: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>; +Cc: Alvaro Herrera <alvherre@kurilemu.de>; Antonin Houska <ah@cybertec.at>; Nathan Bossart <nathandbossart@gmail.com>; pgsql-hackers
On Wed, Sep 9, 2026 at 10:28 AM Bharath Rupireddy
<bharath.rupireddyforpostgres@gmail.com> wrote:
>
> Hi,
>
> On Tue, Sep 8, 2026 at 1:09 PM Masahiko Sawada <sawada.mshk@gmail.com> wrote:
> >
> > Pushed.
>
> Thanks for taking care of this. Please find another remaining patch
> rebased to use detail instead of hints and reword the messages
> consistently in REPACK (CONCURRENTLY) checks.
Thank you for rebasing the patch! Pushed.
Regards,
--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com
^ permalink raw reply [nested|flat] 14+ messages in thread
end of thread, other threads:[~2026-09-09 20:47 UTC | newest]
Thread overview: 14+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-08-27 14:22 REPACK (CONCURRENTLY) rewrites tables marked with user_catalog_table Nathan Bossart <nathandbossart@gmail.com>
2026-08-27 22:46 ` Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-08-29 11:23 ` Antonin Houska <ah@cybertec.at>
2026-08-29 15:34 ` Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-09-01 03:35 ` Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-09-04 18:02 ` Masahiko Sawada <sawada.mshk@gmail.com>
2026-09-04 19:59 ` Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-09-08 12:47 ` Alvaro Herrera <alvherre@kurilemu.de>
2026-09-08 15:58 ` Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-09-08 18:23 ` Masahiko Sawada <sawada.mshk@gmail.com>
2026-09-08 18:57 ` Alvaro Herrera <alvherre@kurilemu.de>
2026-09-08 20:08 ` Masahiko Sawada <sawada.mshk@gmail.com>
2026-09-09 17:28 ` Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
2026-09-09 20:47 ` Masahiko Sawada <sawada.mshk@gmail.com>
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