738
|
opCtx->recoveryUnit()->registerChange(new AddCollectionChange(opCtx, this, ns));
|
739
|
Collection* collection = _getOrCreateCollectionInstance(opCtx, nss);
|
740
|
invariant(collection);
|
741
|
_collections[ns] = collection;
|
742
|
|
743
|
BSONObj fullIdIndexSpec;
|
744
|
|
745
|
if (createIdIndex) {
|
746
|
if (collection->requiresIdIndex()) {
|
747
|
if (optionsWithUUID.autoIndexId == CollectionOptions::YES ||
|
748
|
optionsWithUUID.autoIndexId == CollectionOptions::DEFAULT) {
|
749
|
const auto featureCompatibilityVersion =
|
750
|
serverGlobalParams.featureCompatibility.version.load();
|
751
|
IndexCatalog* ic = collection->getIndexCatalog();
|
752
|
fullIdIndexSpec = uassertStatusOK(ic->createIndexOnEmptyCollection(
|
753
|
opCtx,
|
754
|
!idIndex.isEmpty() ? idIndex
|
755
|
: ic->getDefaultIdIndexSpec(featureCompatibilityVersion)));
|
756
|
}
|
757
|
}
|