agora inbox for [email protected]
help / color / mirror / Atom feed[PATCH] Cover some errors and corner conditions in repack.c
146+ messages / 5 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ 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; 146+ 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] 146+ messages in thread
* [PATCH] Fix memory leak in pg_config
@ 2026-07-21 15:54 Ivan Kush <[email protected]>
0 siblings, 2 replies; 146+ messages in thread
From: Ivan Kush @ 2026-07-21 15:54 UTC (permalink / raw)
To: [email protected]
|Hi, While testing PostgreSQL with LeakSanitizer enabled, I found a
memory leak in pg_config. The issue can be reproduced by running:
pg_config --version LeakSanitizer reports 2829 bytes leaked in 47
allocations. The full report is attached as leak_sanitizer.txt. The
relevant allocation stack is: libc.so.6!__GI___libc_malloc(size_t bytes)
(malloc.c:3288) pg_malloc_internal(size_t size, int flags)
(src/common/fe_memutils.c:36) palloc(Size size)
(src/common/fe_memutils.c:123) palloc_mul(Size s1, Size s2)
(src/common/fe_memutils.c:312) get_configdata(const char *my_exec_path,
size_t *configdata_len) (src/common/config_info.c:42) main(int argc,
char **argv) (src/bin/pg_config/pg_config.c:157) Although
get_configdata() uses palloc_array() and pstrdup(), pg_config is a
frontend program. The frontend implementations of palloc() and pstrdup()
ultimately allocate memory using malloc() and strdup(), through
pg_malloc_internal() and pg_strdup(), respectively. These allocations
are not owned by a backend memory context and therefore remain allocated
until they are explicitly freed or the process exits. get_configdata()
allocates the ConfigData array with palloc_array() and allocates its
name and setting strings with pstrdup(). pg_config does not release
these allocations before exiting. This leak is harmless for a
short-lived process, since the operating system releases the memory at
process termination. However, it causes LeakSanitizer failures and adds
noise to sanitizer-based testing. The attached patch adds a helper that
frees every name and setting string and then frees the ConfigData array.
The helper is called on every exit path reached after get_configdata().
After applying the patch, pg_config --version completes without a
LeakSanitizer report. The patch is attached as:
v1-0001-Fix-memory-leak-in-pg_config.patch |
--
Best wishes,
Ivan Kush
Tantor Labs LLC
=================================================================
==611824==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 368 byte(s) in 1 object(s) allocated from:
#0 0x556274ec32bf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
#1 0x556274f13e53 in pg_malloc_internal /build/src/common/fe_memutils.c:36
#2 0x556274f1427e in palloc /build/src/common/fe_memutils.c:123
#3 0x556274f150f1 in palloc_mul /build/src/common/fe_memutils.c:312
#4 0x556274f0c47a in get_configdata /build/src/common/config_info.c:42
#5 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#6 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 940 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0ddd7 in get_configdata /build/src/common/config_info.c:127
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 395 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e290 in get_configdata /build/src/common/config_info.c:148
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 178 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e5b6 in get_configdata /build/src/common/config_info.c:164
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 153 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e0fd in get_configdata /build/src/common/config_info.c:140
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 112 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0ea6f in get_configdata /build/src/common/config_info.c:188
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 60 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0dc44 in get_configdata /build/src/common/config_info.c:123
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 44 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0cf6f in get_configdata /build/src/common/config_info.c:80
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 39 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0c9fc in get_configdata /build/src/common/config_info.c:62
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 39 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0c82b in get_configdata /build/src/common/config_info.c:56
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 37 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0cd9e in get_configdata /build/src/common/config_info.c:74
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 35 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d884 in get_configdata /build/src/common/config_info.c:110
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 33 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d311 in get_configdata /build/src/common/config_info.c:92
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 33 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0da55 in get_configdata /build/src/common/config_info.c:116
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 31 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d4e2 in get_configdata /build/src/common/config_info.c:98
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 28 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d6b3 in get_configdata /build/src/common/config_info.c:104
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 26 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0cbcd in get_configdata /build/src/common/config_info.c:68
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 22 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0c65a in get_configdata /build/src/common/config_info.c:50
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 22 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d140 in get_configdata /build/src/common/config_info.c:86
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 18 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0ce88 in get_configdata /build/src/common/config_info.c:77
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 16 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0ec02 in get_configdata /build/src/common/config_info.c:195
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 14 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0ccb7 in get_configdata /build/src/common/config_info.c:71
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 11 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e828 in get_configdata /build/src/common/config_info.c:178
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 11 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d96e in get_configdata /build/src/common/config_info.c:113
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 11 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e695 in get_configdata /build/src/common/config_info.c:170
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 11 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0cae6 in get_configdata /build/src/common/config_info.c:65
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 10 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d22a in get_configdata /build/src/common/config_info.c:89
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 10 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0dd23 in get_configdata /build/src/common/config_info.c:126
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 10 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d3fb in get_configdata /build/src/common/config_info.c:95
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 10 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e36f in get_configdata /build/src/common/config_info.c:154
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 9 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d79d in get_configdata /build/src/common/config_info.c:107
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 9 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e049 in get_configdata /build/src/common/config_info.c:138
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 8 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0eb4e in get_configdata /build/src/common/config_info.c:194
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 8 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0c915 in get_configdata /build/src/common/config_info.c:59
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 8 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e502 in get_configdata /build/src/common/config_info.c:162
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 7 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0c4ea in get_configdata /build/src/common/config_info.c:44
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 7 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d059 in get_configdata /build/src/common/config_info.c:83
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 7 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d5cc in get_configdata /build/src/common/config_info.c:101
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 7 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e1dc in get_configdata /build/src/common/config_info.c:146
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 7 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0c744 in get_configdata /build/src/common/config_info.c:53
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 6 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e423 in get_configdata /build/src/common/config_info.c:156
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 5 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0db3f in get_configdata /build/src/common/config_info.c:119
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 5 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e9bb in get_configdata /build/src/common/config_info.c:186
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 4 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0df6a in get_configdata /build/src/common/config_info.c:132
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 3 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0deb6 in get_configdata /build/src/common/config_info.c:130
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 1 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e8dc in get_configdata /build/src/common/config_info.c:180
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 1 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e749 in get_configdata /build/src/common/config_info.c:172
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
SUMMARY: AddressSanitizer: 2829 byte(s) leaked in 47 allocation(s).
root@d9e2ae7524d9:/build#
Attachments:
[text/plain] leak_sanitizer.txt (25.2K, ../../[email protected]/2-leak_sanitizer.txt)
download | inline:
=================================================================
==611824==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 368 byte(s) in 1 object(s) allocated from:
#0 0x556274ec32bf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
#1 0x556274f13e53 in pg_malloc_internal /build/src/common/fe_memutils.c:36
#2 0x556274f1427e in palloc /build/src/common/fe_memutils.c:123
#3 0x556274f150f1 in palloc_mul /build/src/common/fe_memutils.c:312
#4 0x556274f0c47a in get_configdata /build/src/common/config_info.c:42
#5 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#6 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 940 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0ddd7 in get_configdata /build/src/common/config_info.c:127
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 395 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e290 in get_configdata /build/src/common/config_info.c:148
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 178 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e5b6 in get_configdata /build/src/common/config_info.c:164
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 153 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e0fd in get_configdata /build/src/common/config_info.c:140
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 112 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0ea6f in get_configdata /build/src/common/config_info.c:188
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 60 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0dc44 in get_configdata /build/src/common/config_info.c:123
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 44 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0cf6f in get_configdata /build/src/common/config_info.c:80
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 39 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0c9fc in get_configdata /build/src/common/config_info.c:62
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 39 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0c82b in get_configdata /build/src/common/config_info.c:56
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 37 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0cd9e in get_configdata /build/src/common/config_info.c:74
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 35 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d884 in get_configdata /build/src/common/config_info.c:110
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 33 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d311 in get_configdata /build/src/common/config_info.c:92
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 33 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0da55 in get_configdata /build/src/common/config_info.c:116
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 31 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d4e2 in get_configdata /build/src/common/config_info.c:98
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 28 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d6b3 in get_configdata /build/src/common/config_info.c:104
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 26 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0cbcd in get_configdata /build/src/common/config_info.c:68
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 22 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0c65a in get_configdata /build/src/common/config_info.c:50
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 22 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d140 in get_configdata /build/src/common/config_info.c:86
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 18 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0ce88 in get_configdata /build/src/common/config_info.c:77
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 16 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0ec02 in get_configdata /build/src/common/config_info.c:195
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 14 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0ccb7 in get_configdata /build/src/common/config_info.c:71
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 11 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e828 in get_configdata /build/src/common/config_info.c:178
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 11 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d96e in get_configdata /build/src/common/config_info.c:113
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 11 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e695 in get_configdata /build/src/common/config_info.c:170
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 11 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0cae6 in get_configdata /build/src/common/config_info.c:65
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 10 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d22a in get_configdata /build/src/common/config_info.c:89
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 10 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0dd23 in get_configdata /build/src/common/config_info.c:126
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 10 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d3fb in get_configdata /build/src/common/config_info.c:95
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 10 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e36f in get_configdata /build/src/common/config_info.c:154
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 9 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d79d in get_configdata /build/src/common/config_info.c:107
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 9 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e049 in get_configdata /build/src/common/config_info.c:138
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 8 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0eb4e in get_configdata /build/src/common/config_info.c:194
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 8 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0c915 in get_configdata /build/src/common/config_info.c:59
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 8 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e502 in get_configdata /build/src/common/config_info.c:162
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 7 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0c4ea in get_configdata /build/src/common/config_info.c:44
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 7 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d059 in get_configdata /build/src/common/config_info.c:83
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 7 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d5cc in get_configdata /build/src/common/config_info.c:101
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 7 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e1dc in get_configdata /build/src/common/config_info.c:146
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 7 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0c744 in get_configdata /build/src/common/config_info.c:53
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 6 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e423 in get_configdata /build/src/common/config_info.c:156
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 5 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0db3f in get_configdata /build/src/common/config_info.c:119
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 5 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e9bb in get_configdata /build/src/common/config_info.c:186
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 4 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0df6a in get_configdata /build/src/common/config_info.c:132
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 3 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0deb6 in get_configdata /build/src/common/config_info.c:130
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 1 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e8dc in get_configdata /build/src/common/config_info.c:180
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 1 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e749 in get_configdata /build/src/common/config_info.c:172
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
SUMMARY: AddressSanitizer: 2829 byte(s) leaked in 47 allocation(s).
root@d9e2ae7524d9:/build#
[text/x-patch] v1-0001-Fix-memory-leak-in-pg_config.patch (1.3K, ../../[email protected]/3-v1-0001-Fix-memory-leak-in-pg_config.patch)
download | inline diff:
From fcfb081954801183f4c67cfe447c73f22b2dbf9b Mon Sep 17 00:00:00 2001
From: Ivan Kush <[email protected]>
Date: Tue, 21 Jul 2026 15:25:38 +0000
Subject: [PATCH] Fix memory leak in pg_config
---
src/bin/pg_config/pg_config.c | 15 ++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/src/bin/pg_config/pg_config.c b/src/bin/pg_config/pg_config.c
index 28db024263..af99ae8657 100644
--- a/src/bin/pg_config/pg_config.c
+++ b/src/bin/pg_config/pg_config.c
@@ -125,6 +125,17 @@ show_item(const char *configname,
}
}
+static
+void pfree_configdata(ConfigData *configdata, size_t configdata_len)
+{
+ for (size_t i = 0; i < configdata_len; i++)
+ {
+ pfree(configdata[i].name);
+ pfree(configdata[i].setting);
+ }
+ pfree(configdata);
+}
+
int
main(int argc, char **argv)
{
@@ -160,6 +171,7 @@ main(int argc, char **argv)
{
for (i = 0; i < configdata_len; i++)
printf("%s = %s\n", configdata[i].name, configdata[i].setting);
+ pfree_configdata(configdata, configdata_len);
exit(0);
}
@@ -180,9 +192,12 @@ main(int argc, char **argv)
fprintf(stderr, _("%s: invalid argument: %s\n"),
progname, argv[i]);
advice();
+ pfree_configdata(configdata, configdata_len);
exit(1);
}
}
+ pfree_configdata(configdata, configdata_len);
+
return 0;
}
--
2.39.2
^ permalink raw reply [nested|flat] 146+ messages in thread
* Re: [PATCH] Fix memory leak in pg_config
@ 2026-07-21 16:08 Ivan Kush <[email protected]>
parent: Ivan Kush <[email protected]>
1 sibling, 0 replies; 146+ messages in thread
From: Ivan Kush @ 2026-07-21 16:08 UTC (permalink / raw)
To: [email protected]
Sorry for the formatting in my previous email. Resending in plain text.
Hi,
While testing PostgreSQL with LeakSanitizer enabled, I found a memory
leak in pg_config.
The issue can be reproduced by running:
pg_config --version
LeakSanitizer reports 2829 bytes leaked in 47 allocations. The full
report is attached as leak_sanitizer.txt.
The relevant allocation stack is:
libc.so.6!__GI___libc_malloc(size_t bytes) (malloc.c:3288)
pg_malloc_internal(size_t size, int flags)
(src/common/fe_memutils.c:36)
palloc(Size size)
(src/common/fe_memutils.c:123)
palloc_mul(Size s1, Size s2)
(src/common/fe_memutils.c:312)
get_configdata(const char *my_exec_path, size_t *configdata_len)
(src/common/config_info.c:42)
main(int argc, char **argv)
(src/bin/pg_config/pg_config.c:157)
Although get_configdata() uses palloc_array() and pstrdup(), pg_config
is a frontend program. The frontend implementations of palloc() and
pstrdup() ultimately allocate memory using malloc() and strdup(),
through pg_malloc_internal() and pg_strdup(), respectively. These
allocations are not owned by a backend memory context and therefore
remain allocated until they are explicitly freed or the process exits.
get_configdata() allocates the ConfigData array with palloc_array() and
allocates its name and setting strings with pstrdup(). pg_config does
not release these allocations before exiting.
This leak is harmless for a short-lived process, since the operating
system releases the memory at process termination. However, it causes
LeakSanitizer failures and adds noise to sanitizer-based testing.
The attached patch adds a helper that frees every name and setting
string and then frees the ConfigData array. The helper is called on
every exit path reached after get_configdata().
After applying the patch, pg_config --version completes without a
LeakSanitizer report.
The patch is attached as:
v1-0001-Fix-memory-leak-in-pg_config.patch
--
Best wishes,
Ivan Kush
Tantor Labs LLC
=================================================================
==611824==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 368 byte(s) in 1 object(s) allocated from:
#0 0x556274ec32bf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
#1 0x556274f13e53 in pg_malloc_internal /build/src/common/fe_memutils.c:36
#2 0x556274f1427e in palloc /build/src/common/fe_memutils.c:123
#3 0x556274f150f1 in palloc_mul /build/src/common/fe_memutils.c:312
#4 0x556274f0c47a in get_configdata /build/src/common/config_info.c:42
#5 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#6 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 940 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0ddd7 in get_configdata /build/src/common/config_info.c:127
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 395 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e290 in get_configdata /build/src/common/config_info.c:148
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 178 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e5b6 in get_configdata /build/src/common/config_info.c:164
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 153 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e0fd in get_configdata /build/src/common/config_info.c:140
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 112 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0ea6f in get_configdata /build/src/common/config_info.c:188
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 60 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0dc44 in get_configdata /build/src/common/config_info.c:123
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 44 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0cf6f in get_configdata /build/src/common/config_info.c:80
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 39 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0c9fc in get_configdata /build/src/common/config_info.c:62
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 39 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0c82b in get_configdata /build/src/common/config_info.c:56
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 37 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0cd9e in get_configdata /build/src/common/config_info.c:74
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 35 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d884 in get_configdata /build/src/common/config_info.c:110
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 33 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d311 in get_configdata /build/src/common/config_info.c:92
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 33 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0da55 in get_configdata /build/src/common/config_info.c:116
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 31 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d4e2 in get_configdata /build/src/common/config_info.c:98
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 28 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d6b3 in get_configdata /build/src/common/config_info.c:104
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 26 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0cbcd in get_configdata /build/src/common/config_info.c:68
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 22 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0c65a in get_configdata /build/src/common/config_info.c:50
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 22 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d140 in get_configdata /build/src/common/config_info.c:86
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 18 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0ce88 in get_configdata /build/src/common/config_info.c:77
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 16 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0ec02 in get_configdata /build/src/common/config_info.c:195
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 14 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0ccb7 in get_configdata /build/src/common/config_info.c:71
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 11 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e828 in get_configdata /build/src/common/config_info.c:178
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 11 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d96e in get_configdata /build/src/common/config_info.c:113
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 11 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e695 in get_configdata /build/src/common/config_info.c:170
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 11 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0cae6 in get_configdata /build/src/common/config_info.c:65
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 10 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d22a in get_configdata /build/src/common/config_info.c:89
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 10 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0dd23 in get_configdata /build/src/common/config_info.c:126
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 10 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d3fb in get_configdata /build/src/common/config_info.c:95
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 10 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e36f in get_configdata /build/src/common/config_info.c:154
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 9 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d79d in get_configdata /build/src/common/config_info.c:107
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 9 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e049 in get_configdata /build/src/common/config_info.c:138
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 8 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0eb4e in get_configdata /build/src/common/config_info.c:194
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 8 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0c915 in get_configdata /build/src/common/config_info.c:59
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 8 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e502 in get_configdata /build/src/common/config_info.c:162
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 7 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0c4ea in get_configdata /build/src/common/config_info.c:44
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 7 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d059 in get_configdata /build/src/common/config_info.c:83
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 7 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d5cc in get_configdata /build/src/common/config_info.c:101
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 7 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e1dc in get_configdata /build/src/common/config_info.c:146
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 7 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0c744 in get_configdata /build/src/common/config_info.c:53
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 6 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e423 in get_configdata /build/src/common/config_info.c:156
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 5 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0db3f in get_configdata /build/src/common/config_info.c:119
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 5 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e9bb in get_configdata /build/src/common/config_info.c:186
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 4 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0df6a in get_configdata /build/src/common/config_info.c:132
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 3 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0deb6 in get_configdata /build/src/common/config_info.c:130
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 1 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e8dc in get_configdata /build/src/common/config_info.c:180
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 1 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e749 in get_configdata /build/src/common/config_info.c:172
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
SUMMARY: AddressSanitizer: 2829 byte(s) leaked in 47 allocation(s).
root@d9e2ae7524d9:/build#
Attachments:
[text/plain] leak_sanitizer.txt (25.2K, ../../[email protected]/2-leak_sanitizer.txt)
download | inline:
=================================================================
==611824==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 368 byte(s) in 1 object(s) allocated from:
#0 0x556274ec32bf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
#1 0x556274f13e53 in pg_malloc_internal /build/src/common/fe_memutils.c:36
#2 0x556274f1427e in palloc /build/src/common/fe_memutils.c:123
#3 0x556274f150f1 in palloc_mul /build/src/common/fe_memutils.c:312
#4 0x556274f0c47a in get_configdata /build/src/common/config_info.c:42
#5 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#6 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 940 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0ddd7 in get_configdata /build/src/common/config_info.c:127
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 395 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e290 in get_configdata /build/src/common/config_info.c:148
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 178 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e5b6 in get_configdata /build/src/common/config_info.c:164
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 153 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e0fd in get_configdata /build/src/common/config_info.c:140
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 112 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0ea6f in get_configdata /build/src/common/config_info.c:188
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 60 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0dc44 in get_configdata /build/src/common/config_info.c:123
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 44 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0cf6f in get_configdata /build/src/common/config_info.c:80
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 39 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0c9fc in get_configdata /build/src/common/config_info.c:62
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 39 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0c82b in get_configdata /build/src/common/config_info.c:56
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 37 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0cd9e in get_configdata /build/src/common/config_info.c:74
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 35 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d884 in get_configdata /build/src/common/config_info.c:110
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 33 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d311 in get_configdata /build/src/common/config_info.c:92
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 33 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0da55 in get_configdata /build/src/common/config_info.c:116
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 31 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d4e2 in get_configdata /build/src/common/config_info.c:98
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 28 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d6b3 in get_configdata /build/src/common/config_info.c:104
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 26 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0cbcd in get_configdata /build/src/common/config_info.c:68
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 22 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0c65a in get_configdata /build/src/common/config_info.c:50
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 22 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d140 in get_configdata /build/src/common/config_info.c:86
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 18 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0ce88 in get_configdata /build/src/common/config_info.c:77
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 16 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0ec02 in get_configdata /build/src/common/config_info.c:195
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 14 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0ccb7 in get_configdata /build/src/common/config_info.c:71
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 11 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e828 in get_configdata /build/src/common/config_info.c:178
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 11 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d96e in get_configdata /build/src/common/config_info.c:113
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 11 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e695 in get_configdata /build/src/common/config_info.c:170
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 11 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0cae6 in get_configdata /build/src/common/config_info.c:65
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 10 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d22a in get_configdata /build/src/common/config_info.c:89
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 10 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0dd23 in get_configdata /build/src/common/config_info.c:126
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 10 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d3fb in get_configdata /build/src/common/config_info.c:95
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 10 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e36f in get_configdata /build/src/common/config_info.c:154
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 9 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d79d in get_configdata /build/src/common/config_info.c:107
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 9 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e049 in get_configdata /build/src/common/config_info.c:138
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 8 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0eb4e in get_configdata /build/src/common/config_info.c:194
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 8 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0c915 in get_configdata /build/src/common/config_info.c:59
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 8 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e502 in get_configdata /build/src/common/config_info.c:162
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 7 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0c4ea in get_configdata /build/src/common/config_info.c:44
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 7 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d059 in get_configdata /build/src/common/config_info.c:83
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 7 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0d5cc in get_configdata /build/src/common/config_info.c:101
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 7 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e1dc in get_configdata /build/src/common/config_info.c:146
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 7 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0c744 in get_configdata /build/src/common/config_info.c:53
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 6 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e423 in get_configdata /build/src/common/config_info.c:156
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 5 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0db3f in get_configdata /build/src/common/config_info.c:119
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 5 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e9bb in get_configdata /build/src/common/config_info.c:186
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 4 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0df6a in get_configdata /build/src/common/config_info.c:132
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 3 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0deb6 in get_configdata /build/src/common/config_info.c:130
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 1 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e8dc in get_configdata /build/src/common/config_info.c:180
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
Indirect leak of 1 byte(s) in 1 object(s) allocated from:
#0 0x556274e7b0ab in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
#1 0x556274f141d9 in pg_strdup /build/src/common/fe_memutils.c:101
#2 0x556274f142f4 in pstrdup /build/src/common/fe_memutils.c:147
#3 0x556274f0e749 in get_configdata /build/src/common/config_info.c:172
#4 0x556274f0b984 in main /build/src/bin/pg_config/pg_config.c:157
#5 0x7ce486b87249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
SUMMARY: AddressSanitizer: 2829 byte(s) leaked in 47 allocation(s).
root@d9e2ae7524d9:/build#
[text/x-patch] v1-0001-Fix-memory-leak-in-pg_config.patch (1.3K, ../../[email protected]/3-v1-0001-Fix-memory-leak-in-pg_config.patch)
download | inline diff:
From fcfb081954801183f4c67cfe447c73f22b2dbf9b Mon Sep 17 00:00:00 2001
From: Ivan Kush <[email protected]>
Date: Tue, 21 Jul 2026 15:25:38 +0000
Subject: [PATCH] Fix memory leak in pg_config
---
src/bin/pg_config/pg_config.c | 15 ++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/src/bin/pg_config/pg_config.c b/src/bin/pg_config/pg_config.c
index 28db024263..af99ae8657 100644
--- a/src/bin/pg_config/pg_config.c
+++ b/src/bin/pg_config/pg_config.c
@@ -125,6 +125,17 @@ show_item(const char *configname,
}
}
+static void
+pfree_configdata(ConfigData *configdata, size_t configdata_len)
+{
+ for (size_t i = 0; i < configdata_len; i++)
+ {
+ pfree(configdata[i].name);
+ pfree(configdata[i].setting);
+ }
+ pfree(configdata);
+}
+
int
main(int argc, char **argv)
{
@@ -160,6 +171,7 @@ main(int argc, char **argv)
{
for (i = 0; i < configdata_len; i++)
printf("%s = %s\n", configdata[i].name, configdata[i].setting);
+ pfree_configdata(configdata, configdata_len);
exit(0);
}
@@ -180,9 +192,12 @@ main(int argc, char **argv)
fprintf(stderr, _("%s: invalid argument: %s\n"),
progname, argv[i]);
advice();
+ pfree_configdata(configdata, configdata_len);
exit(1);
}
}
+ pfree_configdata(configdata, configdata_len);
+
return 0;
}
--
2.39.2
^ permalink raw reply [nested|flat] 146+ messages in thread
* Re: [PATCH] Fix memory leak in pg_config
@ 2026-07-21 18:35 Andrey Borodin <[email protected]>
parent: Ivan Kush <[email protected]>
1 sibling, 2 replies; 146+ messages in thread
From: Andrey Borodin @ 2026-07-21 18:35 UTC (permalink / raw)
To: Ivan Kush <[email protected]>; +Cc: pgsql-hackers mailing list <[email protected]>
Hi Ivan,
> LeakSanitizer reports 2829 bytes leaked in 47 allocations.
I can confirm the leak and the fix. The 47 allocations are exactly 23
names + 23 settings + 1 array. With your patch the tool reports zero.
Fun archaeology: this leak celebrates its 10th anniversary this year.
It arrived with a5c43b88694 (PG 9.6), which introduced get_configdata()
with the comment "the caller is responsible for pfreeing the result".
pg_config has been ignoring that contract ever since. Before 9.6 it
used static buffers and had nothing to leak at all. Simpler times.
One thing to be aware of: our CI runs sanitizers with
detect_leaks=0, and the comment there says "too many uninteresting
leak errors in short-lived binaries". This leak is a prime specimen
of the genre, so the answer here may well be "the OS frees it faster
than we do". If the goal is quiet LSan runs, a suppression list might
scale better: there are many binaries other than pg_config that leak
too. Anyway, I think it would be good to quite LSan if possible...
Two small notes:
- Validating the arguments before calling get_configdata() would
leave a single free before return instead of three call sites.
- The function definition puts "static" alone on its own line. The
usual style is "static void" together, then the function name on
the next line.
Thank you!
Best regards, Andrey Borodin.
^ permalink raw reply [nested|flat] 146+ messages in thread
* Re: [PATCH] Fix memory leak in pg_config
@ 2026-07-21 19:41 Ivan Kush <[email protected]>
parent: Andrey Borodin <[email protected]>
1 sibling, 0 replies; 146+ messages in thread
From: Ivan Kush @ 2026-07-21 19:41 UTC (permalink / raw)
To: Andrey Borodin <[email protected]>; +Cc: pgsql-hackers mailing list <[email protected]>
Thanks for the review.
LeakSanitizer is widely used tools, so I think it
would be useful to make PostgreSQL work cleanly with them. We could
either fix reported leaks where cleanup is straightforward, or maintain
suppressions for intentional process-lifetime allocations. I prefer
fixing the leaks where possible.
We use these sanitizers in our own work, so we can continue examining
their reports across PostgreSQL, fix actual leaks, add suppressions where
appropriate, and submit the changes as separate patches.
For pg_config, the cleanup is small and straightforward. A broad
suppression for get_configdata() could also hide future leaks from the
same call path.
In v2, I restructured the control flow using if/else, so
free_configdata() is called only once before returning from main().
Invalid arguments now set the exit code and break out of the loop
instead of calling exit().
Personally, I prefer the simpler control flow used in v1.
I also corrected the function definition style.
The updated patch is attached.
On 26-07-21 21:35, Andrey Borodin wrote:
> Hi Ivan,
>
>> LeakSanitizer reports 2829 bytes leaked in 47 allocations.
>
> I can confirm the leak and the fix. The 47 allocations are exactly 23
> names + 23 settings + 1 array. With your patch the tool reports zero.
>
> Fun archaeology: this leak celebrates its 10th anniversary this year.
> It arrived with a5c43b88694 (PG 9.6), which introduced get_configdata()
> with the comment "the caller is responsible for pfreeing the result".
> pg_config has been ignoring that contract ever since. Before 9.6 it
> used static buffers and had nothing to leak at all. Simpler times.
>
> One thing to be aware of: our CI runs sanitizers with
> detect_leaks=0, and the comment there says "too many uninteresting
> leak errors in short-lived binaries". This leak is a prime specimen
> of the genre, so the answer here may well be "the OS frees it faster
> than we do". If the goal is quiet LSan runs, a suppression list might
> scale better: there are many binaries other than pg_config that leak
> too. Anyway, I think it would be good to quite LSan if possible...
>
> Two small notes:
>
> - Validating the arguments before calling get_configdata() would
> leave a single free before return instead of three call sites.
> - The function definition puts "static" alone on its own line. The
> usual style is "static void" together, then the function name on
> the next line.
>
> Thank you!
>
> Best regards, Andrey Borodin.
>
--
Best wishes,
Ivan Kush
Tantor Labs LLC
Attachments:
[text/x-patch] v2-0001-Fix-memory-leak-in-pg_config.patch (2.1K, ../../[email protected]/2-v2-0001-Fix-memory-leak-in-pg_config.patch)
download | inline diff:
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ivan Kush <[email protected]>
Date: Tue, 21 Jul 2026 15:25:38 +0000
Subject: [PATCH v2] Fix memory leak in pg_config
---
src/bin/pg_config/pg_config.c | 48 ++++++++++++++++++++++++++++++++----------------
1 file changed, 32 insertions(+), 16 deletions(-)
diff --git a/src/bin/pg_config/pg_config.c b/src/bin/pg_config/pg_config.c
--- a/src/bin/pg_config/pg_config.c
+++ b/src/bin/pg_config/pg_config.c
@@ -11,6 +11,17 @@
}
}
+static void
+free_configdata(ConfigData *configdata, size_t configdata_len)
+{
+ for (size_t i = 0; i < configdata_len; i++)
+ {
+ pfree(configdata[i].name);
+ pfree(configdata[i].setting);
+ }
+ pfree(configdata);
+}
+
int
main(int argc, char **argv)
{
@@ -19,6 +30,7 @@
char my_exec_path[MAXPGPATH];
int i;
int j;
+ int exit_code = 0;
set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_config"));
@@ -49,29 +61,33 @@
{
for (i = 0; i < configdata_len; i++)
printf("%s = %s\n", configdata[i].name, configdata[i].setting);
- exit(0);
}
-
- /* otherwise print requested items */
- for (i = 1; i < argc; i++)
+ else
{
- for (j = 0; info_items[j].switchname != NULL; j++)
+ /* otherwise print requested items */
+ for (i = 1; i < argc; i++)
{
- if (strcmp(argv[i], info_items[j].switchname) == 0)
+ for (j = 0; info_items[j].switchname != NULL; j++)
+ {
+ if (strcmp(argv[i], info_items[j].switchname) == 0)
+ {
+ show_item(info_items[j].configname,
+ configdata, configdata_len);
+ break;
+ }
+ }
+ if (info_items[j].switchname == NULL)
{
- show_item(info_items[j].configname,
- configdata, configdata_len);
+ fprintf(stderr, _("%s: invalid argument: %s\n"),
+ progname, argv[i]);
+ advice();
+ exit_code = 1;
break;
}
}
- if (info_items[j].switchname == NULL)
- {
- fprintf(stderr, _("%s: invalid argument: %s\n"),
- progname, argv[i]);
- advice();
- exit(1);
- }
}
- return 0;
+ free_configdata(configdata, configdata_len);
+
+ return exit_code;
}
--
2.39.2
^ permalink raw reply [nested|flat] 146+ messages in thread
* Re: [PATCH] Fix memory leak in pg_config
@ 2026-07-21 21:05 Andres Freund <[email protected]>
parent: Andrey Borodin <[email protected]>
1 sibling, 1 reply; 146+ messages in thread
From: Andres Freund @ 2026-07-21 21:05 UTC (permalink / raw)
To: Andrey Borodin <[email protected]>; +Cc: Ivan Kush <[email protected]>; pgsql-hackers mailing list <[email protected]>
Hi,
On 2026-07-21 23:35:18 +0500, Andrey Borodin wrote:
> One thing to be aware of: our CI runs sanitizers with
> detect_leaks=0, and the comment there says "too many uninteresting
> leak errors in short-lived binaries".
So far our policy is that we do not care about leaks in short lived
binaries. I doubt that we need more very verbose projects at this point, so I
don't think we'll want to change this in the near future.
Greetings,
Andres Freund
^ permalink raw reply [nested|flat] 146+ messages in thread
* Re: [PATCH] Fix memory leak in pg_config
@ 2026-07-21 22:38 Michael Paquier <[email protected]>
parent: Andres Freund <[email protected]>
0 siblings, 0 replies; 146+ messages in thread
From: Michael Paquier @ 2026-07-21 22:38 UTC (permalink / raw)
To: Andres Freund <[email protected]>; +Cc: Andrey Borodin <[email protected]>; Ivan Kush <[email protected]>; pgsql-hackers mailing list <[email protected]>
On Tue, Jul 21, 2026 at 05:05:14PM -0400, Andres Freund wrote:
> So far our policy is that we do not care about leaks in short lived
> binaries. I doubt that we need more very verbose projects at this point, so I
> don't think we'll want to change this in the near future.
None of the changes proposed in the patch are worth caring about. The
only memory leaks I would care about in the frontend binaries are
those where we could run a tool in an infinite loop where the
non-freed would bloat. One example of that is pg_receivewal without
--no-loop, that could be used as a service to get WAL from a remote
source.
--
Michael
Attachments:
[application/pgp-signature] signature.asc (833B, ../../[email protected]/2-signature.asc)
download
^ permalink raw reply [nested|flat] 146+ messages in thread
end of thread, other threads:[~2026-07-21 22:38 UTC | newest]
Thread overview: 146+ 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-07-21 15:54 [PATCH] Fix memory leak in pg_config Ivan Kush <[email protected]>
2026-07-21 16:08 ` Re: [PATCH] Fix memory leak in pg_config Ivan Kush <[email protected]>
2026-07-21 18:35 ` Re: [PATCH] Fix memory leak in pg_config Andrey Borodin <[email protected]>
2026-07-21 19:41 ` Re: [PATCH] Fix memory leak in pg_config Ivan Kush <[email protected]>
2026-07-21 21:05 ` Re: [PATCH] Fix memory leak in pg_config Andres Freund <[email protected]>
2026-07-21 22:38 ` Re: [PATCH] Fix memory leak in pg_config Michael Paquier <[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