mirror of
https://github.com/postgres/postgres.git
synced 2026-10-23 13:29:09 +03:00
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
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -291,6 +291,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.
|
||||
|
||||
@@ -911,6 +911,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.
|
||||
|
||||
Reference in New Issue
Block a user