diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c index 11ee128630..e86334106e 100644 --- a/src/backend/catalog/heap.c +++ b/src/backend/catalog/heap.c @@ -1160,11 +1160,16 @@ BuildRelationDistributionNodes(List *nodes, int *numnodes) { Oid *nodeoids; ListCell *item; + int numdatanotes; *numnodes = 0; /* Allocate once enough space for OID array */ - nodeoids = (Oid *) palloc0(NumDataNodes * sizeof(Oid)); + numdatanotes=list_length(nodes); + nodeoids = (Oid *) palloc0(numdatanotes*sizeof(Oid)); + + + /* Do process for each node name */ foreach(item, nodes)