MCPcopy Create free account
hub / github.com/documentdb/documentdb / TrySetCollectionShard

Function TrySetCollectionShard

pg_documentdb/src/metadata/collection.c:600–633  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

598
599
600static void
601TrySetCollectionShard(MongoCollection *collection)
602{
603 if (collection->isShardRemote)
604 {
605 return;
606 }
607
608 int savedGUCLevel = NewGUCNestLevel();
609 SetGUCLocally("client_min_messages", "WARNING");
610
611 /* Get shard table name (distributed) or original tableName (single node) */
612 const char *shardName = TryGetShardNameForUnshardedCollection(
613 collection->relationId, collection->collectionId, collection->tableName);
614 RollbackGUCChange(savedGUCLevel);
615 if (shardName != NULL)
616 {
617 if (shardName[0] == '\0')
618 {
619 collection->shardTableName[0] = '\0';
620 collection->isShardRemote = true;
621 }
622 else
623 {
624 strcpy(collection->shardTableName, shardName);
625 collection->isShardRemote = false;
626 }
627 }
628 else
629 {
630 collection->isShardRemote = false;
631 collection->shardTableName[0] = '\0';
632 }
633}
634
635
636/*

Calls 3

SetGUCLocallyFunction · 0.85
RollbackGUCChangeFunction · 0.85

Tested by

no test coverage detected