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 \
--- /dev/null
+-- 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;
'replorigin',
'time',
'messages',
+ 'repack',
'spill',
'slot',
'truncate',
--- /dev/null
+-- 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;
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);
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
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
--
-- 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.
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;
DROP TABLE clstr_3;
DROP TABLE clstr_4;
DROP TABLE clstr_expression;
+DROP TABLE clstrpart;
DROP USER regress_clstr_user;
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);
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
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;
--
-- 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
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;
DROP TABLE clstr_3;
DROP TABLE clstr_4;
DROP TABLE clstr_expression;
+DROP TABLE clstrpart;
DROP USER regress_clstr_user;