From 71002706f870e245ac1e63c76fd229816e303913 Mon Sep 17 00:00:00 2001 From: Srinath Reddy Sadipiralla Date: Thu, 26 Nov 2026 14:26:48 +0530 Subject: [PATCH v1] psql: Show replica identity of partitioned tables in \d+ \d+ displays a "Replica Identity" footer when a table's replica identity is FULL or NOTHING, but the check covered only ordinary tables and materialized views. Partitioned tables have accepted ALTER TABLE ... REPLICA IDENTITY since declarative partitioning was added; the setting is stored in pg_class.relreplident and pg_dump preserves it, yet \d+ never showed it. The setting is not just informational, when a publication uses publish_via_partition_root, pgoutput sends the partitioned table's replica identity to the subscriber. Hiding it makes a mismatch between a partitioned table and its partitions harder to notice. As for other relation kinds, REPLICA IDENTITY USING INDEX is still shown only as a marker on the index. Reported-by: Faye --- src/bin/psql/describe.c | 1 + src/test/regress/expected/replica_identity.out | 16 ++++++++++++++++ src/test/regress/sql/replica_identity.sql | 3 +++ 3 files changed, 20 insertions(+) diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 23e2b3c51df..2cf49334a32 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3545,6 +3545,7 @@ describeOneTableDetails(const char *schemaname, if (verbose && (tableinfo.relkind == RELKIND_RELATION || + tableinfo.relkind == RELKIND_PARTITIONED_TABLE || tableinfo.relkind == RELKIND_MATVIEW) && /* diff --git a/src/test/regress/expected/replica_identity.out b/src/test/regress/expected/replica_identity.out index 1560cd04125..b67b5a82e83 100644 --- a/src/test/regress/expected/replica_identity.out +++ b/src/test/regress/expected/replica_identity.out @@ -304,6 +304,22 @@ Not-null constraints: Partitions: test_replica_identity4_1 FOR VALUES IN (1) +-- \d+ shows a non-default replica identity of a partitioned table +ALTER TABLE ONLY test_replica_identity4 REPLICA IDENTITY FULL; +\d+ test_replica_identity4 + Partitioned table "public.test_replica_identity4" + Column | Type | Collation | Nullable | Default | Storage | Stats target | Description +--------+---------+-----------+----------+---------+---------+--------------+------------- + id | integer | | not null | | plain | | +Partition key: LIST (id) +Indexes: + "test_replica_identity4_pkey" PRIMARY KEY, btree (id) +Not-null constraints: + "test_replica_identity4_id_not_null" NOT NULL "id" +Partitions: + test_replica_identity4_1 FOR VALUES IN (1) +Replica Identity: FULL + -- Dropping the primary key is not allowed if that would leave the replica -- identity as nullable CREATE TABLE test_replica_identity5 (a int not null, b int, c int, diff --git a/src/test/regress/sql/replica_identity.sql b/src/test/regress/sql/replica_identity.sql index 4ebb097f282..0d24a8ed1d6 100644 --- a/src/test/regress/sql/replica_identity.sql +++ b/src/test/regress/sql/replica_identity.sql @@ -123,6 +123,9 @@ ALTER TABLE ONLY test_replica_identity4_1 ALTER INDEX test_replica_identity4_pkey ATTACH PARTITION test_replica_identity4_1_pkey; \d+ test_replica_identity4 +-- \d+ shows a non-default replica identity of a partitioned table +ALTER TABLE ONLY test_replica_identity4 REPLICA IDENTITY FULL; +\d+ test_replica_identity4 -- Dropping the primary key is not allowed if that would leave the replica -- identity as nullable -- 2.43.0