diff --git a/.unreleased/pr_6897 b/.unreleased/pr_6897 new file mode 100644 index 00000000000..2ec9b6d02e3 --- /dev/null +++ b/.unreleased/pr_6897 @@ -0,0 +1 @@ +Implements: #6897 Add support for replica identity on compressed hypertables diff --git a/src/process_utility.c b/src/process_utility.c index 61594a9d5d3..b580833cc53 100644 --- a/src/process_utility.c +++ b/src/process_utility.c @@ -232,6 +232,7 @@ check_alter_table_allowed_on_ht_with_compression(Hypertable *ht, AlterTableStmt case AT_ColumnDefault: /* this is passed down */ case AT_DropColumn: /* this is passed down */ case AT_DropConstraint: /* this is passed down */ + case AT_ReplicaIdentity: case AT_ReAddStatistics: case AT_SetCompression: continue; diff --git a/tsl/test/expected/compression_ddl.out b/tsl/test/expected/compression_ddl.out index e2a2591a869..84fd25d985c 100644 --- a/tsl/test/expected/compression_ddl.out +++ b/tsl/test/expected/compression_ddl.out @@ -54,6 +54,40 @@ DROP INDEX new_index; ALTER TABLE test1 SET (fillfactor=100); ALTER TABLE test1 RESET (fillfactor); ALTER TABLE test1 ALTER COLUMN b SET STATISTICS 10; +-- ensure that REPLICA IDENTITY works +SELECT relreplident, count(*) FROM show_chunks('test1') ch INNER JOIN pg_class c ON (ch = c.oid) GROUP BY 1 ORDER BY 1; + relreplident | count +--------------+------- + d | 27 +(1 row) + +SELECT relreplident FROM pg_class c WHERE c.relname = 'test1'; + relreplident +-------------- + d +(1 row) + +ALTER TABLE test1 REPLICA IDENTITY FULL; +SELECT relname, relreplident FROM pg_class WHERE relname = 'test1' ORDER BY relname; + relname | relreplident +---------+-------------- + test1 | f +(1 row) + +-- the chunk's setting should also change to FULL +SELECT relreplident, count(*) FROM show_chunks('test1') ch INNER JOIN pg_class c ON (ch = c.oid) GROUP BY 1 ORDER BY 1; + relreplident | count +--------------+------- + f | 27 +(1 row) + +SELECT relreplident FROM pg_class c WHERE c.relname = 'test1'; + relreplident +-------------- + f +(1 row) + +ALTER TABLE test1 REPLICA IDENTITY DEFAULT; -- make sure we cannot create constraints or unique indexes on compressed hypertables \set ON_ERROR_STOP 0 ALTER TABLE test1 ADD CONSTRAINT c1 UNIQUE(time,i); diff --git a/tsl/test/sql/compression_ddl.sql b/tsl/test/sql/compression_ddl.sql index c4bd5ff70b1..ae372ceded1 100644 --- a/tsl/test/sql/compression_ddl.sql +++ b/tsl/test/sql/compression_ddl.sql @@ -34,6 +34,16 @@ ALTER TABLE test1 SET (fillfactor=100); ALTER TABLE test1 RESET (fillfactor); ALTER TABLE test1 ALTER COLUMN b SET STATISTICS 10; +-- ensure that REPLICA IDENTITY works +SELECT relreplident, count(*) FROM show_chunks('test1') ch INNER JOIN pg_class c ON (ch = c.oid) GROUP BY 1 ORDER BY 1; +SELECT relreplident FROM pg_class c WHERE c.relname = 'test1'; +ALTER TABLE test1 REPLICA IDENTITY FULL; +SELECT relname, relreplident FROM pg_class WHERE relname = 'test1' ORDER BY relname; +-- the chunk's setting should also change to FULL +SELECT relreplident, count(*) FROM show_chunks('test1') ch INNER JOIN pg_class c ON (ch = c.oid) GROUP BY 1 ORDER BY 1; +SELECT relreplident FROM pg_class c WHERE c.relname = 'test1'; +ALTER TABLE test1 REPLICA IDENTITY DEFAULT; + -- make sure we cannot create constraints or unique indexes on compressed hypertables \set ON_ERROR_STOP 0 ALTER TABLE test1 ADD CONSTRAINT c1 UNIQUE(time,i);