REPACK (CONCURRENTLY) fails with wrong error for materialized views
Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.
You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:
docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t253600psql -h localhost -U postgresBuilt from patchset v1 (message #1), August 29, 2026 at 04:08 PM.
Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:
git clone --branch t253600_1 https://github.com/hackorum-dev/postgres.gitIn a checkout you already have, add the fork once:
git remote add hackorum https://github.com/hackorum-dev/postgres.gitthen, for this patchset and every later one:
git fetch hackorum t253600_1 && git checkout t253600_1Patchset v1 (message #1) is on t253600_1
Hi,
REPACK (CONCURRENTLY) fails with a confusing "no identity index" error
when a materialized view is specified. Please find attached a patch
that reports a proper error, similar to the other cases in
check_concurrent_repack_requirements(), and adds a note to the docs. I
think this needs to be backpatched to PG19.
Thoughts?
[1]: postgres=# CREATE MATERIALIZED VIEW m AS SELECT 1 AS a; SELECT 1 postgres=# REPACK (CONCURRENTLY) m; ERROR: cannot execute REPACK (CONCURRENTLY) on relation "m" HINT: Relation "m" has no identity index.
postgres=# CREATE MATERIALIZED VIEW m AS SELECT 1 AS a;
SELECT 1
postgres=# REPACK (CONCURRENTLY) m;
ERROR: cannot execute REPACK (CONCURRENTLY) on relation "m"
HINT: Relation "m" has no identity index.
--
Bharath Rupireddy
Amazon Web Services: https://aws.amazon.com
Hi Bharath,
I verified the change, and it works as intended. The new check is
appropriately placed before replica identity validation. The error is much
clearer than the previous "has no identity index" message, and the
documentation update looks good to me.
*My only suggestion is to add an automated* test as it can help catch any
future regressions in this behavior.
*Verified Upstream Commit* - ec13f71049cda06ea55a67783b822d98824f4d15
*Build Status -* Successfully built with assertions enabled. No relevant
compiler warnings were observed.
*Automated Tests Validation -* The complete test suite passed which
includes the related wal level tests.
*Manual Verifications - *Verified that REPACK (CONCURRENTLY) succeeded on
a regular table and preserved all rows. For both populated and unpopulated
materialized views, it returned the expected error and the new
materialized-view-specific hint that you introduced.
Thanks,
Kiran Kaki.
On Sat, Aug 29, 2026 at 8:58 AM Bharath Rupireddy <
bharath.rupireddyforpostgres@gmail.com> wrote:
Show quoted text
Hi,
REPACK (CONCURRENTLY) fails with a confusing "no identity index" error
when a materialized view is specified. Please find attached a patch
that reports a proper error, similar to the other cases in
check_concurrent_repack_requirements(), and adds a note to the docs. I
think this needs to be backpatched to PG19.Thoughts?
[1]
postgres=# CREATE MATERIALIZED VIEW m AS SELECT 1 AS a;
SELECT 1
postgres=# REPACK (CONCURRENTLY) m;
ERROR: cannot execute REPACK (CONCURRENTLY) on relation "m"
HINT: Relation "m" has no identity index.--
Bharath Rupireddy
Amazon Web Services: https://aws.amazon.com