agora inbox for [email protected]help / color / mirror / Atom feed
[PATCH] Cover some errors and corner conditions in repack.c 141+ messages / 2 participants [nested] [flat]
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH] Cover some errors and corner conditions in repack.c @ 2026-05-28 09:20 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Álvaro Herrera @ 2026-05-28 09:20 UTC (permalink / raw) --- src/test/regress/expected/cluster.out | 33 +++++++++++++++++++++++++++ src/test/regress/sql/cluster.sql | 28 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 23f312c62a3..cfbe2764427 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -697,6 +697,39 @@ SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; (4 rows) COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +ERROR: "clstr_idx_b" is not an index for table "clstr_table_one" +CLUSTER clstr_table_one USING nonexistant; +ERROR: index "nonexistant" for table "clstr_table_one" does not exist +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; +ERROR: cannot cluster on index "clstr_hash_idx" because access method does not support clustering +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; +ERROR: cannot cluster on partial index "clstr_partial_idx" +REPACK pg_class USING INDEX pg_class_oid_index; +ERROR: permission denied: "pg_class" is a system catalog +DETAIL: System catalogs can only be clustered by the index they're already clustered on, if any, unless "allow_system_table_mods" is enabled. +DROP TABLE clstr_table_one, clstr_table_two; +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; + ?column? +---------- + t +(1 row) + +DROP MATERIALIZED VIEW clstr_matview; ---------------------------------------------------------------------- -- -- REPACK diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index c2f329ecd1b..1cb1942263c 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -328,6 +328,34 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; COMMIT; +-- verify some error cases +CREATE TABLE clstr_table_one (id int, val text); +CREATE TABLE clstr_table_two (id int, val text); +CREATE INDEX clstr_idx_b ON clstr_table_two (id); +CLUSTER clstr_table_one USING clstr_idx_b; +CLUSTER clstr_table_one USING nonexistant; + +CREATE INDEX clstr_hash_idx ON clstr_table_one USING hash (id); +CLUSTER clstr_table_one USING clstr_hash_idx; + +CREATE INDEX clstr_partial_idx ON clstr_table_one (id) WHERE id > 0; +CLUSTER clstr_table_one USING clstr_partial_idx; + +REPACK pg_class USING INDEX pg_class_oid_index; + +DROP TABLE clstr_table_one, clstr_table_two; + +-- verify that CLUSTER/REPACK don't touch a NO DATA matview +CREATE MATERIALIZED VIEW clstr_matview AS + SELECT i FROM generate_series(1, 5) i + WITH NO DATA; +CREATE INDEX clstr_matview_idx ON clstr_matview (i); +SELECT relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass \gset +CLUSTER clstr_matview USING clstr_matview_idx; +REPACK clstr_matview USING INDEX clstr_matview_idx; +SELECT relfilenode = :relfilenode FROM pg_class WHERE oid = 'clstr_matview'::regclass; +DROP MATERIALIZED VIEW clstr_matview; + ---------------------------------------------------------------------- -- -- REPACK -- 2.47.3 --yrl6wzxda7bokrre-- ^ permalink raw reply [nested|flat] 141+ messages in thread
* [PATCH v8a 14/14] ci: Add back running check support @ 2026-06-03 00:30 Andres Freund <[email protected]> 0 siblings, 0 replies; 141+ messages in thread From: Andres Freund @ 2026-06-03 00:30 UTC (permalink / raw) --- .github/workflows/pg-ci.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/.github/workflows/pg-ci.yml b/.github/workflows/pg-ci.yml index af986b351bf..86efa1cbe76 100644 --- a/.github/workflows/pg-ci.yml +++ b/.github/workflows/pg-ci.yml @@ -479,6 +479,36 @@ jobs: LANG: C run: *meson_test_world_cmd + # Test running against existing PG instance. + # + # linux-meson-32 chosen because it's currently comparatively fast + - name: Test running + shell: *su_postgres_shell + run: | + ulimit -c unlimited + + # Ensure install exists, in case somebody is debugging a failing + # test within this an reorders this before "Test world" + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + # Make libraries discoverable (the x86_64 reference is a meson + # oddity) + export LD_LIBRARY_PATH="$(pwd)/build/tmp_install/usr/local/pgsql/lib/x86_64-linux-gnu/:$LD_LIBRARY_PATH" + + build/tmp_install/usr/local/pgsql/bin/initdb -N build/runningcheck --no-instructions -A trust + echo "include '$(pwd)/src/tools/ci/pg_ci_base.conf'" >> build/runningcheck/postgresql.conf + + # Log into a place that will be archived in case of failure + mkdir -p build/testrun + build/tmp_install/usr/local/pgsql/bin/pg_ctl -c -o '-c fsync=off' -D build/runningcheck -l build/testrun/runningcheck.log start + + # Run the tests supporting running against an already running + meson test $MTEST_ARGS --num-processes ${TEST_JOBS} --setup running + + build/tmp_install/usr/local/pgsql/bin/pg_ctl -D build/runningcheck stop + - *linux_collect_cores - *upload_logs_step -- 2.54.0.380.gc69baaf57b --vphnza2cz5zw5t4a-- ^ permalink raw reply [nested|flat] 141+ messages in thread
end of thread, other threads:[~2026-06-03 00:30 UTC | newest] Thread overview: 141+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-05-28 09:20 [PATCH] Cover some errors and corner conditions in repack.c Álvaro Herrera <[email protected]> 2026-06-03 00:30 [PATCH v8a 14/14] ci: Add back running check support Andres Freund <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox