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

Function command_unshard_collection

pg_documentdb/src/sharding/sharding.c:253–286  ·  view source on GitHub ↗

* Top level command to unshard a collection. */

Source from the content-addressed store, hash-verified

251 * Top level command to unshard a collection.
252 */
253Datum
254command_unshard_collection(PG_FUNCTION_ARGS)
255{
256 pgbson *shardArg = PG_GETARG_PGBSON_PACKED(0);
257
258 if (!IsMetadataCoordinator())
259 {
260 StringInfo shardCollectionQuery = makeStringInfo();
261 appendStringInfo(shardCollectionQuery,
262 "SELECT %s.unshard_collection(%s::%s.bson)",
263 ApiSchemaNameV2,
264 quote_literal_cstr(PgbsonToHexadecimalString(shardArg)),
265 CoreSchemaNameV2);
266 DistributedRunCommandResult result = RunCommandOnMetadataCoordinator(
267 shardCollectionQuery->data);
268
269 if (!result.success)
270 {
271 ereport(ERROR, (errcode(ERRCODE_DOCUMENTDB_INTERNALERROR),
272 errmsg(
273 "Internal error unsharding collection in metadata coordinator"),
274 errdetail_log(
275 "Internal error unsharding collection in metadata coordinator via distributed call %s",
276 text_to_cstring(result.response))));
277 }
278
279 PG_RETURN_VOID();
280 }
281
282 ShardCollectionArgs args = { 0 };
283 ParseUnshardCollectionRequest(shardArg, &args);
284 ShardCollectionCore(&args);
285 PG_RETURN_VOID();
286}
287
288
289/*

Callers

nothing calls this directly

Calls 5

IsMetadataCoordinatorFunction · 0.85
ShardCollectionCoreFunction · 0.85

Tested by

no test coverage detected