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