mirror of https://github.com/citusdata/citus.git
Apply feedback
parent
3a04374a9e
commit
2b0c4accda
|
@ -553,11 +553,7 @@ CreateShardsOnWorkers(Oid distributedRelationId, List *shardPlacements,
|
||||||
{
|
{
|
||||||
List *placementAccessList = NIL;
|
List *placementAccessList = NIL;
|
||||||
|
|
||||||
/* we only need to calculate this once per shardInterval, not placement */
|
|
||||||
if (relationShardList == NIL)
|
|
||||||
{
|
|
||||||
relationShardList = RelationShardListForShardCreate(shardInterval);
|
relationShardList = RelationShardListForShardCreate(shardInterval);
|
||||||
}
|
|
||||||
|
|
||||||
placementAccessList = BuildPlacementDDLList(shardPlacement->groupId,
|
placementAccessList = BuildPlacementDDLList(shardPlacement->groupId,
|
||||||
relationShardList);
|
relationShardList);
|
||||||
|
@ -617,6 +613,7 @@ RelationShardListForShardCreate(ShardInterval *shardInterval)
|
||||||
List *allForeignKeyRelations =
|
List *allForeignKeyRelations =
|
||||||
list_concat_unique_oid(referencedRelationList, referencingRelationList);
|
list_concat_unique_oid(referencedRelationList, referencingRelationList);
|
||||||
int shardIndex = -1;
|
int shardIndex = -1;
|
||||||
|
ListCell *fkeyRelationIdCell = NULL;
|
||||||
|
|
||||||
/* record the placement access of the shard itself */
|
/* record the placement access of the shard itself */
|
||||||
relationShard = CitusMakeNode(RelationShard);
|
relationShard = CitusMakeNode(RelationShard);
|
||||||
|
@ -630,14 +627,11 @@ RelationShardListForShardCreate(ShardInterval *shardInterval)
|
||||||
shardIndex = ShardIndex(shardInterval);
|
shardIndex = ShardIndex(shardInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* all foregin constraint relations */
|
|
||||||
if (allForeignKeyRelations != NIL)
|
|
||||||
{
|
|
||||||
ListCell *relationIdCell = NULL;
|
|
||||||
|
|
||||||
foreach(relationIdCell, allForeignKeyRelations)
|
/* all foregin key constraint relations */
|
||||||
|
foreach(fkeyRelationIdCell, allForeignKeyRelations)
|
||||||
{
|
{
|
||||||
Oid fkeyRelationid = lfirst_oid(relationIdCell);
|
Oid fkeyRelationid = lfirst_oid(fkeyRelationIdCell);
|
||||||
RelationShard *fkeyRelationShard = NULL;
|
RelationShard *fkeyRelationShard = NULL;
|
||||||
uint64 fkeyShardId = INVALID_SHARD_ID;
|
uint64 fkeyShardId = INVALID_SHARD_ID;
|
||||||
|
|
||||||
|
@ -677,13 +671,16 @@ RelationShardListForShardCreate(ShardInterval *shardInterval)
|
||||||
|
|
||||||
relationShardList = lappend(relationShardList, fkeyRelationShard);
|
relationShardList = lappend(relationShardList, fkeyRelationShard);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* if partitioned table, make sure to record the parent table */
|
/* if partitioned table, make sure to record the parent table */
|
||||||
if (PartitionTable(relationId))
|
if (PartitionTable(relationId))
|
||||||
{
|
{
|
||||||
RelationShard *parentRelationShard = CitusMakeNode(RelationShard);
|
RelationShard *parentRelationShard = CitusMakeNode(RelationShard);
|
||||||
|
|
||||||
|
/* partitioned tables are always co-located */
|
||||||
|
Assert(shardIndex != -1);
|
||||||
|
|
||||||
parentRelationShard->relationId = PartitionParentOid(relationId);
|
parentRelationShard->relationId = PartitionParentOid(relationId);
|
||||||
parentRelationShard->shardId =
|
parentRelationShard->shardId =
|
||||||
ColocatedShardIdInRelation(parentRelationShard->relationId, shardIndex);
|
ColocatedShardIdInRelation(parentRelationShard->relationId, shardIndex);
|
||||||
|
|
Loading…
Reference in New Issue