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

Function command_reshard_collection

pg_documentdb/src/sharding/sharding.c:214–247  ·  view source on GitHub ↗

* Top level command to reshard a collection. */

Source from the content-addressed store, hash-verified

212 * Top level command to reshard a collection.
213 */
214Datum
215command_reshard_collection(PG_FUNCTION_ARGS)
216{
217 pgbson *shardArg = PG_GETARG_PGBSON_PACKED(0);
218
219 if (!IsMetadataCoordinator())
220 {
221 StringInfo shardCollectionQuery = makeStringInfo();
222 appendStringInfo(shardCollectionQuery,
223 "SELECT %s.reshard_collection(%s::%s.bson)",
224 ApiSchemaNameV2,
225 quote_literal_cstr(PgbsonToHexadecimalString(shardArg)),
226 CoreSchemaNameV2);
227 DistributedRunCommandResult result = RunCommandOnMetadataCoordinator(
228 shardCollectionQuery->data);
229
230 if (!result.success)
231 {
232 ereport(ERROR, (errcode(ERRCODE_DOCUMENTDB_INTERNALERROR),
233 errmsg(
234 "Metadata coordinator encountered internal error while resharding the collection"),
235 errdetail_log(
236 "Metadata coordinator encountered internal error while resharding the collection via distributed call %s",
237 text_to_cstring(result.response))));
238 }
239
240 PG_RETURN_VOID();
241 }
242
243 ShardCollectionArgs args = { 0 };
244 ParseReshardCollectionRequest(shardArg, &args);
245 ShardCollectionCore(&args);
246 PG_RETURN_VOID();
247}
248
249
250/*

Callers

nothing calls this directly

Calls 5

IsMetadataCoordinatorFunction · 0.85
ShardCollectionCoreFunction · 0.85

Tested by

no test coverage detected