From f4d5773f7355f4f9c341c986a580a63890528e9d Mon Sep 17 00:00:00 2001 From: Brian Cloutier Date: Wed, 19 Oct 2016 19:03:27 +0300 Subject: [PATCH] Conditionally read INT4 or INT8 from nodePort --- .../distributed/commands/create_distributed_table.c | 4 ++-- .../distributed/master/master_metadata_utility.c | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/backend/distributed/commands/create_distributed_table.c b/src/backend/distributed/commands/create_distributed_table.c index 8659758b0..2b56a134c 100644 --- a/src/backend/distributed/commands/create_distributed_table.c +++ b/src/backend/distributed/commands/create_distributed_table.c @@ -291,8 +291,8 @@ master_create_distributed_table(PG_FUNCTION_ARGS) CharGetDatum(distributionMethod); newValues[Anum_pg_dist_partition_partkey - 1] = CStringGetTextDatum(distributionKeyString); - newValues[Anum_pg_dist_partition_colocationid - 1] = Int64GetDatum( - INVALID_COLOCATION_ID); + newValues[Anum_pg_dist_partition_colocationid - 1] = + Int64GetDatum(INVALID_COLOCATION_ID); newValues[Anum_pg_dist_partition_repmodel - 1] = CharGetDatum(replicationModel); newTuple = heap_form_tuple(RelationGetDescr(pgDistPartition), newValues, newNulls); diff --git a/src/backend/distributed/master/master_metadata_utility.c b/src/backend/distributed/master/master_metadata_utility.c index ee1462c79..da176db4a 100644 --- a/src/backend/distributed/master/master_metadata_utility.c +++ b/src/backend/distributed/master/master_metadata_utility.c @@ -325,6 +325,8 @@ TupleToShardPlacement(TupleDesc tupleDescriptor, HeapTuple heapTuple) { ShardPlacement *shardPlacement = NULL; bool isNull = false; + Oid nodePortAttTypeId = + tupleDescriptor->attrs[Anum_pg_dist_shard_placement_nodeport - 1]->atttypid; Datum placementId = heap_getattr(heapTuple, Anum_pg_dist_shard_placement_placementid, tupleDescriptor, &isNull); @@ -350,7 +352,14 @@ TupleToShardPlacement(TupleDesc tupleDescriptor, HeapTuple heapTuple) shardPlacement->shardLength = DatumGetInt64(shardLength); shardPlacement->shardState = DatumGetUInt32(shardState); shardPlacement->nodeName = TextDatumGetCString(nodeName); - shardPlacement->nodePort = DatumGetInt32(nodePort); + if (nodePortAttTypeId == INT4OID) + { + shardPlacement->nodePort = DatumGetInt32(nodePort); + } + else + { + shardPlacement->nodePort = DatumGetInt64(nodePort); + } return shardPlacement; }