From 4993487f5e8750b708e76181bb78eddea933d897 Mon Sep 17 00:00:00 2001 From: Petr Jelinek Date: Sat, 22 Apr 2017 20:43:16 +0200 Subject: [PATCH] Properly initialize memory for logical replication relation cache We missed setting some of the properties of the cache entry sometimes, use memset to ensure entry is always fully cleaned up. --- src/backend/replication/logical/relation.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/backend/replication/logical/relation.c b/src/backend/replication/logical/relation.c index 875a081..5bc54dd 100644 --- a/src/backend/replication/logical/relation.c +++ b/src/backend/replication/logical/relation.c @@ -141,19 +141,10 @@ logicalrep_relmap_free_entry(LogicalRepRelMapEntry *entry) pfree(remoterel->attnames); pfree(remoterel->atttyps); } - remoterel->attnames = NULL; - remoterel->atttyps = NULL; - bms_free(remoterel->attkeys); - remoterel->attkeys = NULL; if (entry->attrmap) pfree(entry->attrmap); - - entry->attrmap = NULL; - remoterel->natts = 0; - entry->localreloid = InvalidOid; - entry->localrel = NULL; } /* @@ -182,6 +173,8 @@ logicalrep_relmap_update(LogicalRepRelation *remoterel) if (found) logicalrep_relmap_free_entry(entry); + memset(entry, 0, sizeof(LogicalRepRelMapEntry)); + /* Make cached copy of the data */ oldctx = MemoryContextSwitchTo(LogicalRepRelMapContext); entry->remoterel.remoteid = remoterel->remoteid; @@ -197,8 +190,6 @@ logicalrep_relmap_update(LogicalRepRelation *remoterel) } entry->remoterel.replident = remoterel->replident; entry->remoterel.attkeys = bms_copy(remoterel->attkeys); - entry->attrmap = NULL; - entry->localreloid = InvalidOid; MemoryContextSwitchTo(oldctx); } -- 2.7.4