diff options
author | David Storch <david.storch@10gen.com> | 2016-06-03 10:14:59 -0700 |
---|---|---|
committer | David Storch <david.storch@10gen.com> | 2016-06-03 15:01:33 -0700 |
commit | 681372e942244307067b39c5fe2b27069f5fbbe7 (patch) | |
tree | 51090ca3624082cd4ff470c41c3b313b283a3c5b /src/mongo | |
parent | 10e662cad7fe15581c6c499b934b7d4fd3a1e83d (diff) | |
download | mongo-681372e942244307067b39c5fe2b27069f5fbbe7.tar.gz |
SERVER-24272 add invariant() that IndexDescriptors are non-null in StageBuilder::build()
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/query/stage_builder.cpp | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/src/mongo/db/query/stage_builder.cpp b/src/mongo/db/query/stage_builder.cpp index 2039dc1a5f1..c4fa081c8e9 100644 --- a/src/mongo/db/query/stage_builder.cpp +++ b/src/mongo/db/query/stage_builder.cpp @@ -92,11 +92,7 @@ PlanStage* buildStages(OperationContext* txn, params.descriptor = collection->getIndexCatalog()->findIndexByKeyPattern(txn, ixn->indexKeyPattern); - if (params.descriptor == NULL) { - warning() << "Can't find index " << ixn->indexKeyPattern.toString() << "in namespace " - << collection->ns() << endl; - return NULL; - } + invariant(params.descriptor); params.bounds = ixn->bounds; params.direction = ixn->direction; @@ -228,12 +224,7 @@ PlanStage* buildStages(OperationContext* txn, IndexDescriptor* twoDIndex = collection->getIndexCatalog()->findIndexByKeyPattern(txn, node->indexKeyPattern); - - if (twoDIndex == NULL) { - warning() << "Can't find 2D index " << node->indexKeyPattern.toString() - << "in namespace " << collection->ns() << endl; - return NULL; - } + invariant(twoDIndex); GeoNear2DStage* nearStage = new GeoNear2DStage(params, txn, ws, collection, twoDIndex); @@ -250,12 +241,7 @@ PlanStage* buildStages(OperationContext* txn, IndexDescriptor* s2Index = collection->getIndexCatalog()->findIndexByKeyPattern(txn, node->indexKeyPattern); - - if (s2Index == NULL) { - warning() << "Can't find 2DSphere index " << node->indexKeyPattern.toString() - << "in namespace " << collection->ns() << endl; - return NULL; - } + invariant(s2Index); return new GeoNear2DSphereStage(params, txn, ws, collection, s2Index); } else if (STAGE_TEXT == root->getType()) { @@ -306,6 +292,7 @@ PlanStage* buildStages(OperationContext* txn, params.descriptor = collection->getIndexCatalog()->findIndexByKeyPattern(txn, dn->indexKeyPattern); + invariant(params.descriptor); params.direction = dn->direction; params.bounds = dn->bounds; params.fieldNo = dn->fieldNo; @@ -322,6 +309,7 @@ PlanStage* buildStages(OperationContext* txn, params.descriptor = collection->getIndexCatalog()->findIndexByKeyPattern(txn, csn->indexKeyPattern); + invariant(params.descriptor); params.startKey = csn->startKey; params.startKeyInclusive = csn->startKeyInclusive; params.endKey = csn->endKey; |