1
0
mirror of https://github.com/postgres/postgres.git synced 2026-10-23 13:29:09 +03:00

psql: Fix \d+ display of REPLICA IDENTITY NOTHING

Commit 18954ce7f6 has replaced hardcoded relreplident values in
describe.c with CppAsString2 macros, but used a DEFAULT instead of a
NOTHING at one location.  This caused \d+ on a table with REPLICA
IDENTITY NOTHING to show incorrect data.

Author: Shinya Kato <shinya11.kato@gmail.com>
Discussion: https://postgr.es/m/CAOzEurRHWt+9XLBrbXQOSVkE45NksJ4F28twuqgZ7veW0RzpUQ@mail.gmail.com
Backpatch-through: 18
This commit is contained in:
Michael Paquier
2026-08-17 09:21:08 +09:00
parent 0391fee2dc
commit baa7b142aa
3 changed files with 26 additions and 1 deletions

View File

@@ -3590,7 +3590,7 @@ describeOneTableDetails(const char *schemaname,
printfPQExpBuffer(&buf, "%s: %s",
s,
tableinfo.relreplident == REPLICA_IDENTITY_FULL ? "FULL" :
tableinfo.relreplident == REPLICA_IDENTITY_DEFAULT ? "NOTHING" :
tableinfo.relreplident == REPLICA_IDENTITY_NOTHING ? "NOTHING" :
"???");
printTableAddFooter(&cont, buf.data);

View File

@@ -187,6 +187,30 @@ SELECT relreplident FROM pg_class WHERE oid = 'test_replica_identity'::regclass;
n
(1 row)
\d+ test_replica_identity
Table "public.test_replica_identity"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
--------+---------+-----------+----------+---------------------------------------------------+----------+--------------+-------------
id | integer | | not null | nextval('test_replica_identity_id_seq'::regclass) | plain | |
keya | text | | not null | | extended | |
keyb | text | | not null | | extended | |
nonkey | text | | | | extended | |
Indexes:
"test_replica_identity_pkey" PRIMARY KEY, btree (id)
"test_replica_identity_expr" UNIQUE, btree (keya, keyb, (3))
"test_replica_identity_hash" hash (nonkey)
"test_replica_identity_keyab" btree (keya, keyb)
"test_replica_identity_keyab_key" UNIQUE, btree (keya, keyb)
"test_replica_identity_nonkey" UNIQUE, btree (keya, nonkey)
"test_replica_identity_partial" UNIQUE, btree (keya, keyb) WHERE keyb <> '3'::text
"test_replica_identity_unique_defer" UNIQUE CONSTRAINT, btree (keya, keyb) DEFERRABLE
"test_replica_identity_unique_nondefer" UNIQUE CONSTRAINT, btree (keya, keyb)
Not-null constraints:
"test_replica_identity_id_not_null" NOT NULL "id"
"test_replica_identity_keya_not_null" NOT NULL "keya"
"test_replica_identity_keyb_not_null" NOT NULL "keyb"
Replica Identity: NOTHING
---
-- Test that ALTER TABLE rewrite preserves nondefault replica identity
---

View File

@@ -77,6 +77,7 @@ SELECT relreplident FROM pg_class WHERE oid = 'test_replica_identity'::regclass;
\d+ test_replica_identity
ALTER TABLE test_replica_identity REPLICA IDENTITY NOTHING;
SELECT relreplident FROM pg_class WHERE oid = 'test_replica_identity'::regclass;
\d+ test_replica_identity
---
-- Test that ALTER TABLE rewrite preserves nondefault replica identity