From 91d8a41ecd035301f3bcdca39e2c51549024e8a2 Mon Sep 17 00:00:00 2001 From: Hadi Moshayedi Date: Tue, 9 Jul 2019 12:44:48 -0700 Subject: [PATCH] Don't modify cache entry in RelationShardListForShardCreate() --- src/backend/distributed/master/master_stage_protocol.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/backend/distributed/master/master_stage_protocol.c b/src/backend/distributed/master/master_stage_protocol.c index f6dbabaf1..f34cd5e1e 100644 --- a/src/backend/distributed/master/master_stage_protocol.c +++ b/src/backend/distributed/master/master_stage_protocol.c @@ -728,11 +728,15 @@ RelationShardListForShardCreate(ShardInterval *shardInterval) DistTableCacheEntry *cacheEntry = DistributedTableCacheEntry(relationId); List *referencedRelationList = cacheEntry->referencedRelationsViaForeignKey; List *referencingRelationList = cacheEntry->referencingRelationsViaForeignKey; - List *allForeignKeyRelations = - list_concat_unique_oid(referencedRelationList, referencingRelationList); + List *allForeignKeyRelations = NIL; int shardIndex = -1; ListCell *fkeyRelationIdCell = NULL; + /* list_concat_*() modifies the first arg, so make a copy first */ + allForeignKeyRelations = list_copy(referencedRelationList); + allForeignKeyRelations = list_concat_unique_oid(allForeignKeyRelations, + referencingRelationList); + /* record the placement access of the shard itself */ relationShard = CitusMakeNode(RelationShard); relationShard->relationId = relationId;