]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Move REPACK (CONCURRENTLY) test out of stock regression tests
authorÁlvaro Herrera <alvherre@kurilemu.de>
Thu, 23 Apr 2026 10:34:41 +0000 (12:34 +0200)
committerÁlvaro Herrera <alvherre@kurilemu.de>
Thu, 23 Apr 2026 10:34:41 +0000 (12:34 +0200)
These tests sometimes run with wal_level=minimal, which does not allow
to run REPACK (CONCURRENTLY).  Move them to test_decoding, which is
ensured to run with high enough wal_level.

Discussion: https://postgr.es/m/260901.1776696126@sss.pgh.pa.us

contrib/test_decoding/Makefile
contrib/test_decoding/expected/repack.out [new file with mode: 0644]
contrib/test_decoding/meson.build
contrib/test_decoding/sql/repack.sql [new file with mode: 0644]
src/test/regress/expected/cluster.out
src/test/regress/sql/cluster.sql

index acbcaed2febfb65426d98a64b74594f34c25ddba..0111124399a8e5561cdd48d3845b62ade049b308 100644 (file)
@@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin"
 
 REGRESS = ddl xact rewrite toast permissions decoding_in_xact \
        decoding_into_rel binary prepared replorigin time messages \
-       spill slot truncate stream stats twophase twophase_stream
+       repack spill slot truncate stream stats twophase twophase_stream
 ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \
        oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \
        twophase_snapshot slot_creation_error catalog_change_snapshot \
diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out
new file mode 100644 (file)
index 0000000..1f99f26
--- /dev/null
@@ -0,0 +1,31 @@
+-- Test REPACK (CONCURRENTLY).
+-- This test isn't strictly about logical decoding per se, but
+-- REPACK (CONCURRENTLY) involves logical decoding and therefore requires
+-- to be run under higher than minimal wal_level, so we can't have them in
+-- the main regression test suite.
+-- Ownership of partitions is checked
+CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i);
+CREATE INDEX ptnowner_i_idx ON ptnowner(i);
+CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1);
+CREATE ROLE regress_ptnowner;
+CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2);
+ALTER TABLE ptnowner1 OWNER TO regress_ptnowner;
+SET SESSION AUTHORIZATION regress_ptnowner;
+ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key;
+REPACK (CONCURRENTLY) ptnowner1;
+RESET SESSION AUTHORIZATION;
+ALTER TABLE ptnowner OWNER TO regress_ptnowner;
+CREATE TEMP TABLE ptnowner_oldnodes AS
+  SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree
+  JOIN pg_class AS c ON c.oid=tree.relid;
+SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a
+  JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C";
+  relname  | ?column? 
+-----------+----------
+ ptnowner  | t
+ ptnowner1 | t
+ ptnowner2 | t
+(3 rows)
+
+DROP TABLE ptnowner;
+DROP ROLE regress_ptnowner;
index cf5b74cf1abde026bc5badf9d3dfd76e36fc5865..ac655853d269c610d1556f58bd6811d0114c8d7e 100644 (file)
@@ -34,6 +34,7 @@ tests += {
       'replorigin',
       'time',
       'messages',
+      'repack',
       'spill',
       'slot',
       'truncate',
diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql
new file mode 100644 (file)
index 0000000..c3bfae6
--- /dev/null
@@ -0,0 +1,25 @@
+-- Test REPACK (CONCURRENTLY).
+-- This test isn't strictly about logical decoding per se, but
+-- REPACK (CONCURRENTLY) involves logical decoding and therefore requires
+-- to be run under higher than minimal wal_level, so we can't have them in
+-- the main regression test suite.
+
+-- Ownership of partitions is checked
+CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i);
+CREATE INDEX ptnowner_i_idx ON ptnowner(i);
+CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1);
+CREATE ROLE regress_ptnowner;
+CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2);
+ALTER TABLE ptnowner1 OWNER TO regress_ptnowner;
+SET SESSION AUTHORIZATION regress_ptnowner;
+ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key;
+REPACK (CONCURRENTLY) ptnowner1;
+RESET SESSION AUTHORIZATION;
+ALTER TABLE ptnowner OWNER TO regress_ptnowner;
+CREATE TEMP TABLE ptnowner_oldnodes AS
+  SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree
+  JOIN pg_class AS c ON c.oid=tree.relid;
+SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a
+  JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C";
+DROP TABLE ptnowner;
+DROP ROLE regress_ptnowner;
index 712701349851c30f6188da367809a8c2a17609ca..96089bb0fa20ecc9d8547a2008c020ec1e5f9bdc 100644 (file)
@@ -537,11 +537,6 @@ SELECT relname, old.level, old.relkind, old.relfilenode = new.relfilenode FROM o
  clstrpart33 |     2 | r       | f
 (7 rows)
 
--- CONCURRENTLY doesn't like partitioned tables
-REPACK (CONCURRENTLY) clstrpart;
-ERROR:  REPACK (CONCURRENTLY) is not supported for partitioned tables
-HINT:  Consider running the command on individual partitions.
-DROP TABLE clstrpart;
 -- Ownership of partitions is checked
 CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i);
 CREATE INDEX ptnowner_i_idx ON ptnowner(i);
@@ -552,8 +547,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner;
 SET SESSION AUTHORIZATION regress_ptnowner;
 CLUSTER ptnowner USING ptnowner_i_idx;
 ERROR:  permission denied for table ptnowner
-ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key;
-REPACK (CONCURRENTLY) ptnowner1;
 RESET SESSION AUTHORIZATION;
 ALTER TABLE ptnowner OWNER TO regress_ptnowner;
 CREATE TEMP TABLE ptnowner_oldnodes AS
@@ -562,30 +555,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS
 SET SESSION AUTHORIZATION regress_ptnowner;
 CLUSTER ptnowner USING ptnowner_i_idx;
 WARNING:  permission denied to execute CLUSTER on "ptnowner2", skipping it
--- still can't repack without a replica identity
-ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT;
-REPACK (CONCURRENTLY) ptnowner1;
-ERROR:  cannot process relation "ptnowner1"
-HINT:  Relation "ptnowner1" has no identity index.
 RESET SESSION AUTHORIZATION;
-SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a
-  JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C";
-  relname  | ?column? 
------------+----------
- ptnowner  | t
- ptnowner1 | f
- ptnowner2 | t
-(3 rows)
-
-SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a
-  JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C";
-  relname  | ?column? 
------------+----------
- ptnowner  | t
- ptnowner1 | f
- ptnowner2 | t
-(3 rows)
-
 DROP TABLE ptnowner;
 DROP ROLE regress_ptnowner;
 -- Test CLUSTER with external tuplesorting
@@ -731,6 +701,10 @@ COMMIT;
 --
 -- REPACK
 --
+-- Note we cannot test working REPACK (CONCURRENTLY) here, because the
+-- tests are sometimes run with wal_level=minimal.  Tests for that appear
+-- elsewhere.
+--
 ----------------------------------------------------------------------
 -- REPACK handles individual tables identically to CLUSTER, but it's worth
 -- checking if it handles table hierarchies identically as well.
@@ -822,10 +796,14 @@ ORDER BY o.relname;
  clstr_3
 (2 rows)
 
--- concurrently
+-- concurrently disallowed in catalogs
 REPACK (CONCURRENTLY) pg_class;
 ERROR:  cannot repack relation "pg_class"
 HINT:  REPACK CONCURRENTLY is not supported for catalog relations.
+-- CONCURRENTLY doesn't like partitioned tables
+REPACK (CONCURRENTLY) clstrpart;
+ERROR:  REPACK (CONCURRENTLY) is not supported for partitioned tables
+HINT:  Consider running the command on individual partitions.
 -- clean up
 DROP TABLE clustertest;
 DROP TABLE clstr_1;
@@ -833,4 +811,5 @@ DROP TABLE clstr_2;
 DROP TABLE clstr_3;
 DROP TABLE clstr_4;
 DROP TABLE clstr_expression;
+DROP TABLE clstrpart;
 DROP USER regress_clstr_user;
index 6746236ffec3b67a164a1eadd10e71d1e73d879a..6b3219bab94c69fe4ab894d68f75a68bf2b6b563 100644 (file)
@@ -248,11 +248,6 @@ REPACK clstrpart;
 CREATE TEMP TABLE new_cluster_info AS SELECT relname, level, relfilenode, relkind FROM pg_partition_tree('clstrpart'::regclass) AS tree JOIN pg_class c ON c.oid=tree.relid ;
 SELECT relname, old.level, old.relkind, old.relfilenode = new.relfilenode FROM old_cluster_info AS old JOIN new_cluster_info AS new USING (relname) ORDER BY relname COLLATE "C";
 
--- CONCURRENTLY doesn't like partitioned tables
-REPACK (CONCURRENTLY) clstrpart;
-
-DROP TABLE clstrpart;
-
 -- Ownership of partitions is checked
 CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i);
 CREATE INDEX ptnowner_i_idx ON ptnowner(i);
@@ -262,8 +257,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2);
 ALTER TABLE ptnowner1 OWNER TO regress_ptnowner;
 SET SESSION AUTHORIZATION regress_ptnowner;
 CLUSTER ptnowner USING ptnowner_i_idx;
-ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key;
-REPACK (CONCURRENTLY) ptnowner1;
 RESET SESSION AUTHORIZATION;
 ALTER TABLE ptnowner OWNER TO regress_ptnowner;
 CREATE TEMP TABLE ptnowner_oldnodes AS
@@ -271,14 +264,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS
   JOIN pg_class AS c ON c.oid=tree.relid;
 SET SESSION AUTHORIZATION regress_ptnowner;
 CLUSTER ptnowner USING ptnowner_i_idx;
--- still can't repack without a replica identity
-ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT;
-REPACK (CONCURRENTLY) ptnowner1;
 RESET SESSION AUTHORIZATION;
-SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a
-  JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C";
-SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a
-  JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C";
 DROP TABLE ptnowner;
 DROP ROLE regress_ptnowner;
 
@@ -346,6 +332,10 @@ COMMIT;
 --
 -- REPACK
 --
+-- Note we cannot test working REPACK (CONCURRENTLY) here, because the
+-- tests are sometimes run with wal_level=minimal.  Tests for that appear
+-- elsewhere.
+--
 ----------------------------------------------------------------------
 
 -- REPACK handles individual tables identically to CLUSTER, but it's worth
@@ -393,9 +383,12 @@ JOIN relnodes_new n ON o.relname = n.relname
 WHERE o.relfilenode <> n.relfilenode
 ORDER BY o.relname;
 
--- concurrently
+-- concurrently disallowed in catalogs
 REPACK (CONCURRENTLY) pg_class;
 
+-- CONCURRENTLY doesn't like partitioned tables
+REPACK (CONCURRENTLY) clstrpart;
+
 -- clean up
 DROP TABLE clustertest;
 DROP TABLE clstr_1;
@@ -403,5 +396,6 @@ DROP TABLE clstr_2;
 DROP TABLE clstr_3;
 DROP TABLE clstr_4;
 DROP TABLE clstr_expression;
+DROP TABLE clstrpart;
 
 DROP USER regress_clstr_user;