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

Function CopyIndexSpec

pg_documentdb/src/metadata/index.c:1360–1408  ·  view source on GitHub ↗

* CopyIndexSpec returns a copy of given IndexSpec. */

Source from the content-addressed store, hash-verified

1358 * CopyIndexSpec returns a copy of given IndexSpec.
1359 */
1360IndexSpec *
1361CopyIndexSpec(const IndexSpec *indexSpec)
1362{
1363 IndexSpec *copiedIndexSpec = palloc0(sizeof(IndexSpec));
1364
1365 copiedIndexSpec->indexName = pstrdup(indexSpec->indexName);
1366 copiedIndexSpec->indexKeyDocument =
1367 CopyPgbsonIntoMemoryContext(indexSpec->indexKeyDocument, CurrentMemoryContext);
1368
1369 if (indexSpec->indexPFEDocument)
1370 {
1371 copiedIndexSpec->indexPFEDocument =
1372 CopyPgbsonIntoMemoryContext(indexSpec->indexPFEDocument,
1373 CurrentMemoryContext);
1374 }
1375
1376 if (indexSpec->indexWPDocument)
1377 {
1378 copiedIndexSpec->indexWPDocument =
1379 CopyPgbsonIntoMemoryContext(indexSpec->indexWPDocument,
1380 CurrentMemoryContext);
1381 }
1382
1383 copiedIndexSpec->indexSparse = indexSpec->indexSparse;
1384 copiedIndexSpec->indexUnique = indexSpec->indexUnique;
1385 copiedIndexSpec->indexVersion = indexSpec->indexVersion;
1386
1387 if (indexSpec->indexExpireAfterSeconds)
1388 {
1389 copiedIndexSpec->indexExpireAfterSeconds = palloc0(sizeof(int));
1390 *copiedIndexSpec->indexExpireAfterSeconds = *indexSpec->indexExpireAfterSeconds;
1391 }
1392
1393 if (indexSpec->cosmosSearchOptions)
1394 {
1395 copiedIndexSpec->cosmosSearchOptions = CopyPgbsonIntoMemoryContext(
1396 indexSpec->cosmosSearchOptions,
1397 CurrentMemoryContext);
1398 }
1399
1400 if (indexSpec->indexOptions)
1401 {
1402 copiedIndexSpec->indexOptions = CopyPgbsonIntoMemoryContext(
1403 indexSpec->indexOptions,
1404 CurrentMemoryContext);
1405 }
1406
1407 return copiedIndexSpec;
1408}
1409
1410
1411/*

Callers 3

FindIndexWithSpecOptionsFunction · 0.85
RecordCollectionIndexFunction · 0.85

Calls 1

Tested by

no test coverage detected