| 598 | |
| 599 | |
| 600 | static void |
| 601 | TrySetCollectionShard(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 | /* |
no test coverage detected