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

Function CopyMongoCollection

pg_documentdb/src/metadata/collection.c:288–309  ·  view source on GitHub ↗

* CopyMongoCollection returns a copy of given MongoCollection. */

Source from the content-addressed store, hash-verified

286 * CopyMongoCollection returns a copy of given MongoCollection.
287 */
288MongoCollection *
289CopyMongoCollection(const MongoCollection *collection)
290{
291 MongoCollection *copiedCollection = palloc0(sizeof(MongoCollection));
292
293 *copiedCollection = *collection;
294 copiedCollection->shardKey = !copiedCollection->shardKey ? NULL :
295 CopyPgbsonIntoMemoryContext(copiedCollection->shardKey,
296 CurrentMemoryContext);
297 copiedCollection->viewDefinition = !copiedCollection->viewDefinition ? NULL :
298 CopyPgbsonIntoMemoryContext(
299 copiedCollection->viewDefinition,
300 CurrentMemoryContext);
301
302 copiedCollection->schemaValidator.validator =
303 !copiedCollection->schemaValidator.validator ? NULL :
304 CopyPgbsonIntoMemoryContext(
305 copiedCollection->schemaValidator.validator,
306 CurrentMemoryContext);
307
308 return copiedCollection;
309}
310
311
312/*

Callers 2

Calls 1

Tested by

no test coverage detected