aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/tablecmds.c
diff options
context:
space:
mode:
authorAmit Kapila <akapila@postgresql.org>2021-11-16 09:05:51 +0530
committerAmit Kapila <akapila@postgresql.org>2021-11-16 09:05:51 +0530
commit9816e2d3182681f0cdd31b5b0d15cfb2d62cc784 (patch)
tree87b28df2c891b1fd341d3fc8321b5364d3325da0 /src/backend/commands/tablecmds.c
parent523adcc12900d67a3a43bc7ca4ef4e84f062bb9a (diff)
downloadpostgresql-9816e2d3182681f0cdd31b5b0d15cfb2d62cc784.tar.gz
postgresql-9816e2d3182681f0cdd31b5b0d15cfb2d62cc784.zip
Invalidate relcache when changing REPLICA IDENTITY index.
When changing REPLICA IDENTITY INDEX to another one, the target table's relcache was not being invalidated. This leads to skipping update/delete operations during apply on the subscriber side as the columns required to search corresponding rows won't get logged. Author: Tang Haiying, Hou Zhijie Reviewed-by: Euler Taveira, Amit Kapila Backpatch-through: 10 Discussion: https://postgr.es/m/OS0PR01MB61133CA11630DAE45BC6AD95FB939@OS0PR01MB6113.jpnprd01.prod.outlook.com
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r--src/backend/commands/tablecmds.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index fe6ee63f6a6..dc0001a089e 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -14411,6 +14411,12 @@ relation_mark_replica_identity(Relation rel, char ri_type, Oid indexOid,
CatalogTupleUpdate(pg_index, &pg_index_tuple->t_self, pg_index_tuple);
InvokeObjectPostAlterHookArg(IndexRelationId, thisIndexOid, 0,
InvalidOid, is_internal);
+ /*
+ * Invalidate the relcache for the table, so that after we commit
+ * all sessions will refresh the table's replica identity index
+ * before attempting any UPDATE or DELETE on the table.
+ */
+ CacheInvalidateRelcache(rel);
}
heap_freetuple(pg_index_tuple);
}