Return a deep copy shard list from ColocatedShardIntervalList()

pull/1145/head
Metin Doslu 2017-01-19 17:11:44 +02:00
parent 7cff8719c2
commit ed77260aa1
1 changed files with 10 additions and 2 deletions

View File

@ -841,7 +841,11 @@ ColocatedShardIntervalList(ShardInterval *shardInterval)
if ((partitionMethod == DISTRIBUTE_BY_APPEND) ||
(partitionMethod == DISTRIBUTE_BY_RANGE))
{
colocatedShardList = lappend(colocatedShardList, shardInterval);
ShardInterval *copyShardInterval = CitusMakeNode(ShardInterval);
CopyShardInterval(shardInterval, copyShardInterval);
colocatedShardList = lappend(colocatedShardList, copyShardInterval);
return colocatedShardList;
}
@ -857,6 +861,7 @@ ColocatedShardIntervalList(ShardInterval *shardInterval)
DistTableCacheEntry *colocatedTableCacheEntry =
DistributedTableCacheEntry(colocatedTableId);
ShardInterval *colocatedShardInterval = NULL;
ShardInterval *copyShardInterval = NULL;
/*
* Since we iterate over co-located tables, shard count of each table should be
@ -868,7 +873,10 @@ ColocatedShardIntervalList(ShardInterval *shardInterval)
colocatedShardInterval =
colocatedTableCacheEntry->sortedShardIntervalArray[shardIntervalIndex];
colocatedShardList = lappend(colocatedShardList, colocatedShardInterval);
copyShardInterval = CitusMakeNode(ShardInterval);
CopyShardInterval(colocatedShardInterval, copyShardInterval);
colocatedShardList = lappend(colocatedShardList, copyShardInterval);
}
Assert(list_length(colocatedTableList) == list_length(colocatedShardList));