diff options
Diffstat (limited to 'src/mongo/db/query/query_solution.cpp')
-rw-r--r-- | src/mongo/db/query/query_solution.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/mongo/db/query/query_solution.cpp b/src/mongo/db/query/query_solution.cpp index ed9ab70b4cc..aa2426954c4 100644 --- a/src/mongo/db/query/query_solution.cpp +++ b/src/mongo/db/query/query_solution.cpp @@ -52,31 +52,33 @@ OrderedIntervalList buildStringBoundsOil(const std::string& keyName) { BSONObjBuilder strBob; strBob.appendMinForType("", BSONType::String); strBob.appendMaxForType("", BSONType::String); - ret.intervals.push_back(IndexBoundsBuilder::makeRangeInterval(strBob.obj(), true, false)); + ret.intervals.push_back( + IndexBoundsBuilder::makeRangeInterval(strBob.obj(), BoundInclusion::kIncludeStartKeyOnly)); BSONObjBuilder objBob; objBob.appendMinForType("", BSONType::Object); objBob.appendMaxForType("", BSONType::Object); - ret.intervals.push_back(IndexBoundsBuilder::makeRangeInterval(objBob.obj(), true, false)); + ret.intervals.push_back( + IndexBoundsBuilder::makeRangeInterval(objBob.obj(), BoundInclusion::kIncludeStartKeyOnly)); BSONObjBuilder arrBob; arrBob.appendMinForType("", BSONType::Array); arrBob.appendMaxForType("", BSONType::Array); - ret.intervals.push_back(IndexBoundsBuilder::makeRangeInterval(arrBob.obj(), true, false)); + ret.intervals.push_back( + IndexBoundsBuilder::makeRangeInterval(arrBob.obj(), BoundInclusion::kIncludeStartKeyOnly)); return ret; } bool rangeCanContainString(const BSONElement& startKey, const BSONElement& endKey, - bool endKeyInclusive) { + BoundInclusion boundInclusion) { OrderedIntervalList stringBoundsOil = buildStringBoundsOil(""); OrderedIntervalList rangeOil; BSONObjBuilder bob; bob.appendAs(startKey, ""); bob.appendAs(endKey, ""); - rangeOil.intervals.push_back( - IndexBoundsBuilder::makeRangeInterval(bob.obj(), true, endKeyInclusive)); + rangeOil.intervals.push_back(IndexBoundsBuilder::makeRangeInterval(bob.obj(), boundInclusion)); IndexBoundsBuilder::intersectize(rangeOil, &stringBoundsOil); return !stringBoundsOil.intervals.empty(); @@ -606,8 +608,11 @@ std::set<StringData> IndexScanNode::getFieldsWithStringBounds(const IndexBounds& BSONElement endKey = endKeyIterator.next(); if (SimpleBSONElementComparator::kInstance.evaluate(startKey != endKey) || CollationIndexKey::isCollatableType(startKey.type())) { - if (!rangeCanContainString( - startKey, endKey, (startKeyIterator.more() || bounds.endKeyInclusive))) { + BoundInclusion boundInclusion = bounds.boundInclusion; + if (startKeyIterator.more()) { + boundInclusion = BoundInclusion::kIncludeBothStartAndEndKeys; + } + if (!rangeCanContainString(startKey, endKey, boundInclusion)) { // If the first non-point range cannot contain strings, we don't need to // add it to the return set. keyPatternIterator.next(); |