diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out
index ce2cadfa222..2dd3891b869 100644
--- a/contrib/test_decoding/expected/repack.out
+++ b/contrib/test_decoding/expected/repack.out
@@ -87,6 +87,12 @@ REPACK (CONCURRENTLY) repack_conc_unlogged;
ERROR: cannot execute REPACK (CONCURRENTLY) on relation "repack_conc_unlogged"
HINT: REPACK (CONCURRENTLY) is only allowed for permanent relations.
DROP TABLE repack_conc_unlogged;
+-- Doesn't support materialized views
+CREATE MATERIALIZED VIEW repack_conc_matview AS SELECT 1 AS i;
+REPACK (CONCURRENTLY) repack_conc_matview;
+ERROR: cannot execute REPACK (CONCURRENTLY) on relation "repack_conc_matview"
+DETAIL: This operation is not supported for materialized views.
+DROP MATERIALIZED VIEW repack_conc_matview;
-- 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;
diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql
index eb891009baf..e995c72d28d 100644
--- a/contrib/test_decoding/sql/repack.sql
+++ b/contrib/test_decoding/sql/repack.sql
@@ -64,6 +64,11 @@ CREATE UNLOGGED TABLE repack_conc_unlogged (i int PRIMARY KEY);
REPACK (CONCURRENTLY) repack_conc_unlogged;
DROP TABLE repack_conc_unlogged;
+-- Doesn't support materialized views
+CREATE MATERIALIZED VIEW repack_conc_matview AS SELECT 1 AS i;
+REPACK (CONCURRENTLY) repack_conc_matview;
+DROP MATERIALIZED VIEW repack_conc_matview;
+
-- 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;
diff --git a/doc/src/sgml/ref/repack.sgml b/doc/src/sgml/ref/repack.sgml
index f9fc45b9575..20426cda4ca 100644
--- a/doc/src/sgml/ref/repack.sgml
+++ b/doc/src/sgml/ref/repack.sgml
@@ -261,6 +261,12 @@ REPACK [ ( option [, ...] ) ] USING
following cases:
+
+
+ The relation is not a table (e.g., it is a materialized view).
+
+
+
The table is UNLOGGED.
diff --git a/src/backend/commands/repack.c b/src/backend/commands/repack.c
index 57f28f1a420..4521ccd036f 100644
--- a/src/backend/commands/repack.c
+++ b/src/backend/commands/repack.c
@@ -945,6 +945,14 @@ check_concurrent_repack_requirements(Relation rel, Oid *ident_idx_p)
errhint("%s is only allowed for permanent relations.",
"REPACK (CONCURRENTLY)"));
+ /* A materialized view produces no logically decoded changes. */
+ if (rel->rd_rel->relkind == RELKIND_MATVIEW)
+ ereport(ERROR,
+ errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot execute %s on relation \"%s\"",
+ "REPACK (CONCURRENTLY)", RelationGetRelationName(rel)),
+ errdetail_relkind_not_supported(rel->rd_rel->relkind));
+
/*
* With NOTHING, WAL does not contain the old tuple; FULL is not yet
* supported.