* CopyMongoCollection returns a copy of given MongoCollection. */
| 286 | * CopyMongoCollection returns a copy of given MongoCollection. |
| 287 | */ |
| 288 | MongoCollection * |
| 289 | CopyMongoCollection(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 | /* |
no test coverage detected