mirror of
https://github.com/postgres/postgres.git
synced 2025-05-11 05:41:32 +03:00
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
This commit is contained in:
parent
61c21ddad0
commit
e84d243b1c
@ -82,7 +82,7 @@ logicalrep_relmap_invalidate_cb(Datum arg, Oid reloid)
|
|||||||
* Initialize the relation map cache.
|
* Initialize the relation map cache.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
logicalrep_relmap_init()
|
logicalrep_relmap_init(void)
|
||||||
{
|
{
|
||||||
HASHCTL ctl;
|
HASHCTL ctl;
|
||||||
|
|
||||||
@ -141,19 +141,10 @@ logicalrep_relmap_free_entry(LogicalRepRelMapEntry *entry)
|
|||||||
pfree(remoterel->attnames);
|
pfree(remoterel->attnames);
|
||||||
pfree(remoterel->atttyps);
|
pfree(remoterel->atttyps);
|
||||||
}
|
}
|
||||||
remoterel->attnames = NULL;
|
|
||||||
remoterel->atttyps = NULL;
|
|
||||||
|
|
||||||
bms_free(remoterel->attkeys);
|
bms_free(remoterel->attkeys);
|
||||||
remoterel->attkeys = NULL;
|
|
||||||
|
|
||||||
if (entry->attrmap)
|
if (entry->attrmap)
|
||||||
pfree(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)
|
if (found)
|
||||||
logicalrep_relmap_free_entry(entry);
|
logicalrep_relmap_free_entry(entry);
|
||||||
|
|
||||||
|
memset(entry, 0, sizeof(LogicalRepRelMapEntry));
|
||||||
|
|
||||||
/* Make cached copy of the data */
|
/* Make cached copy of the data */
|
||||||
oldctx = MemoryContextSwitchTo(LogicalRepRelMapContext);
|
oldctx = MemoryContextSwitchTo(LogicalRepRelMapContext);
|
||||||
entry->remoterel.remoteid = remoterel->remoteid;
|
entry->remoterel.remoteid = remoterel->remoteid;
|
||||||
@ -197,8 +190,6 @@ logicalrep_relmap_update(LogicalRepRelation *remoterel)
|
|||||||
}
|
}
|
||||||
entry->remoterel.replident = remoterel->replident;
|
entry->remoterel.replident = remoterel->replident;
|
||||||
entry->remoterel.attkeys = bms_copy(remoterel->attkeys);
|
entry->remoterel.attkeys = bms_copy(remoterel->attkeys);
|
||||||
entry->attrmap = NULL;
|
|
||||||
entry->localreloid = InvalidOid;
|
|
||||||
MemoryContextSwitchTo(oldctx);
|
MemoryContextSwitchTo(oldctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user