From: Álvaro Herrera Date: Thu, 23 Apr 2026 10:34:41 +0000 (+0200) Subject: Move REPACK (CONCURRENTLY) test out of stock regression tests X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=4b2aa4b39cbac71d9795ff760af3991a681eae00;p=thirdparty%2Fpostgresql.git Move REPACK (CONCURRENTLY) test out of stock regression tests 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 --- diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -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 index 00000000000..1f99f26c1f8 --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -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; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -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 index 00000000000..c3bfae61f7f --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -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; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..96089bb0fa2 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -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; diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..6b3219bab94 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -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;