agora inbox for pgsql-hackers@postgresql.orghelp / color / mirror / Atom feed
[PATCH] Revert replica identity to 'default' if the index is dropped 1+ messages / 1 participants [nested] [flat]
* [PATCH] Revert replica identity to 'default' if the index is dropped @ 2026-09-10 10:21 Álvaro Herrera <alvherre@kurilemu.de> 0 siblings, 0 replies; 1+ messages in thread From: Álvaro Herrera @ 2026-09-10 10:21 UTC (permalink / raw) --- contrib/test_decoding/expected/ddl.out | 6 +++--- src/backend/catalog/index.c | 12 ++++++++++++ src/backend/commands/tablecmds.c | 2 +- src/include/commands/tablecmds.h | 4 ++++ 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/contrib/test_decoding/expected/ddl.out b/contrib/test_decoding/expected/ddl.out index a129c016d2b..b403d9e06cb 100644 --- a/contrib/test_decoding/expected/ddl.out +++ b/contrib/test_decoding/expected/ddl.out @@ -828,7 +828,7 @@ table public.table_dropped_index_with_pk: INSERT: a[integer]:2 b[integer]:2 c[in table public.table_dropped_index_with_pk: INSERT: a[integer]:3 b[integer]:3 c[integer]:3 COMMIT BEGIN -table public.table_dropped_index_with_pk: UPDATE: a[integer]:4 b[integer]:1 c[integer]:1 +table public.table_dropped_index_with_pk: UPDATE: old-key: a[integer]:1 new-tuple: a[integer]:4 b[integer]:1 c[integer]:1 COMMIT BEGIN table public.table_dropped_index_with_pk: UPDATE: a[integer]:2 b[integer]:5 c[integer]:2 @@ -837,10 +837,10 @@ BEGIN table public.table_dropped_index_with_pk: UPDATE: a[integer]:3 b[integer]:6 c[integer]:7 COMMIT BEGIN -table public.table_dropped_index_with_pk: DELETE: (no-tuple-data) +table public.table_dropped_index_with_pk: DELETE: a[integer]:4 COMMIT BEGIN -table public.table_dropped_index_with_pk: DELETE: (no-tuple-data) +table public.table_dropped_index_with_pk: DELETE: a[integer]:3 COMMIT BEGIN table public.table_dropped_index_no_pk: INSERT: a[integer]:1 b[integer]:1 c[integer]:1 diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index ec21b83b6b8..144a7a6acc7 100644 --- a/src/backend/catalog/index.c +++ b/src/backend/catalog/index.c @@ -2352,6 +2352,18 @@ index_drop(Oid indexId, bool concurrent, bool concurrent_lock_mode) TransferPredicateLocksToHeapRelation(userIndexRelation); } + /* + * If this index is the replica identity of its table, mark the table as + * having default replica identity. + */ + if (userHeapRelation->rd_rel->relreplident == REPLICA_IDENTITY_INDEX && + RelationGetReplicaIndex(userHeapRelation) == indexId) + { + relation_mark_replica_identity(userHeapRelation, REPLICA_IDENTITY_DEFAULT, + InvalidOid, true); + CommandCounterIncrement(); + } + /* * Schedule physical removal of the files (if any) */ diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 8dc70bfa0f1..1040240f560 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -19065,7 +19065,7 @@ ATExecDropOf(Relation rel, LOCKMODE lockmode) * Caller had better hold an exclusive lock on the relation, as the results * of running two of these concurrently wouldn't be pretty. */ -static void +void /* XXX removal of static not for commit */ relation_mark_replica_identity(Relation rel, char ri_type, Oid indexOid, bool is_internal) { diff --git a/src/include/commands/tablecmds.h b/src/include/commands/tablecmds.h index c3d8518cb62..22b5472d19c 100644 --- a/src/include/commands/tablecmds.h +++ b/src/include/commands/tablecmds.h @@ -45,6 +45,10 @@ extern void AlterTableInternal(Oid relid, List *cmds, bool recurse); extern Oid AlterTableMoveAll(AlterTableMoveAllStmt *stmt); +/* XXX not for commit */ +extern void relation_mark_replica_identity(Relation rel, char ri_type, Oid indexOid, + bool is_internal); + extern ObjectAddress AlterTableNamespace(AlterObjectSchemaStmt *stmt, Oid *oldschema); -- 2.47.3 --csvqstbdygoam7e5-- ^ permalink raw reply [nested|flat] 1+ messages in thread
only message in thread Thread overview: 1+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-09-10 10:21 [PATCH] Revert replica identity to 'default' if the index is dropped Álvaro Herrera <alvherre@kurilemu.de>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox