Skip to content

Commit e84d243

Browse files
committed
Initialize all memory for logical replication relation cache.
As reported by buildfarm animal skink / valgrind, some of the variables weren't always initialized. To avoid further mishaps use memset to ensure the entire entry is initialized. Author: Petr Jelinek Reported-By: Andres Freund Discussion: https://postgr.es/m/20170422183123.w2jgiuxtts7qrqaq@alap3.anarazel.de Backpatch: none, code new in master
1 parent 61c21dd commit e84d243

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

src/backend/replication/logical/relation.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ logicalrep_relmap_invalidate_cb(Datum arg, Oid reloid)
8282
* Initialize the relation map cache.
8383
*/
8484
static void
85-
logicalrep_relmap_init()
85+
logicalrep_relmap_init(void)
8686
{
8787
HASHCTL ctl;
8888

@@ -141,19 +141,10 @@ logicalrep_relmap_free_entry(LogicalRepRelMapEntry *entry)
141141
pfree(remoterel->attnames);
142142
pfree(remoterel->atttyps);
143143
}
144-
remoterel->attnames = NULL;
145-
remoterel->atttyps = NULL;
146-
147144
bms_free(remoterel->attkeys);
148-
remoterel->attkeys = NULL;
149145

150146
if (entry->attrmap)
151147
pfree(entry->attrmap);
152-
153-
entry->attrmap = NULL;
154-
remoterel->natts = 0;
155-
entry->localreloid = InvalidOid;
156-
entry->localrel = NULL;
157148
}
158149

159150
/*
@@ -182,6 +173,8 @@ logicalrep_relmap_update(LogicalRepRelation *remoterel)
182173
if (found)
183174
logicalrep_relmap_free_entry(entry);
184175

176+
memset(entry, 0, sizeof(LogicalRepRelMapEntry));
177+
185178
/* Make cached copy of the data */
186179
oldctx = MemoryContextSwitchTo(LogicalRepRelMapContext);
187180
entry->remoterel.remoteid = remoterel->remoteid;
@@ -197,8 +190,6 @@ logicalrep_relmap_update(LogicalRepRelation *remoterel)
197190
}
198191
entry->remoterel.replident = remoterel->replident;
199192
entry->remoterel.attkeys = bms_copy(remoterel->attkeys);
200-
entry->attrmap = NULL;
201-
entry->localreloid = InvalidOid;
202193
MemoryContextSwitchTo(oldctx);
203194
}
204195

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy