Fix NULL nodeClusterString crush on pg_worker_list.conf migrations

pull/1551/head
Eren Başak 2017-08-14 13:18:53 +03:00
parent b3d2f9ba71
commit 77626c4238
1 changed files with 11 additions and 1 deletions

View File

@ -1424,7 +1424,17 @@ TupleToWorkerNode(TupleDesc tupleDescriptor, HeapTuple heapTuple)
{
Name nodeClusterName = DatumGetName(nodeCluster);
char *nodeClusterString = NameStr(*nodeClusterName);
strlcpy(workerNode->nodeCluster, nodeClusterString, NAMEDATALEN);
/*
* nodeClusterString can be null if nodecluster column is not present.
* In the case of extension creation/upgrade, master_initialize_node_metadata
* function is called before the nodecluster column is added to pg_dist_node
* table.
*/
if (nodeClusterString != NULL)
{
strlcpy(workerNode->nodeCluster, nodeClusterString, NAMEDATALEN);
}
}
return workerNode;