summaryrefslogtreecommitdiff
path: root/src/mongo/db/query
diff options
context:
space:
mode:
authorJames Wahlin <james@mongodb.com>2018-05-04 14:24:37 -0400
committerJames Wahlin <james@mongodb.com>2018-05-11 08:55:34 -0400
commit737596d7005ae061809cbd8483ba91b4a2a89d86 (patch)
tree4a6787ee0f4818f459934c65af025a67c39034bf /src/mongo/db/query
parent714b97ba9c7dd8de3351eb811befce6c4b6efd63 (diff)
downloadmongo-737596d7005ae061809cbd8483ba91b4a2a89d86.tar.gz
SERVER-34851 Disallow index selection for identical min & max values on find
Diffstat (limited to 'src/mongo/db/query')
-rw-r--r--src/mongo/db/query/query_planner.cpp2
-rw-r--r--src/mongo/db/query/query_planner_collation_test.cpp13
-rw-r--r--src/mongo/db/query/query_planner_common.cpp2
-rw-r--r--src/mongo/db/query/query_planner_test.cpp7
4 files changed, 3 insertions, 21 deletions
diff --git a/src/mongo/db/query/query_planner.cpp b/src/mongo/db/query/query_planner.cpp
index 1e49b615c97..7e77db9b567 100644
--- a/src/mongo/db/query/query_planner.cpp
+++ b/src/mongo/db/query/query_planner.cpp
@@ -704,7 +704,7 @@ StatusWith<std::vector<std::unique_ptr<QuerySolution>>> QueryPlanner::plan(
// Now we have the final min and max. This index is only relevant for
// the min/max query if min < max.
- if (0 >=
+ if (0 >
finishedMinObj.woCompare(finishedMaxObj, indexEntry.keyPattern, false)) {
// Found a relevant index.
idxNo = i;
diff --git a/src/mongo/db/query/query_planner_collation_test.cpp b/src/mongo/db/query/query_planner_collation_test.cpp
index 54a549723c8..97860b36add 100644
--- a/src/mongo/db/query/query_planner_collation_test.cpp
+++ b/src/mongo/db/query/query_planner_collation_test.cpp
@@ -220,19 +220,6 @@ TEST_F(QueryPlannerTest, MinMaxWithStringBoundsCannotBeCoveredWithCollator) {
"{locale: 'reverse'}, node: {ixscan: {pattern: {a: 1, b: 1}}}}}}}");
}
-TEST_F(QueryPlannerTest, MinMaxWithoutStringBoundsBoundsCanBeCoveredWithCollator) {
- CollatorInterfaceMock collator(CollatorInterfaceMock::MockType::kReverseString);
- addIndex(fromjson("{a: 1, b: 1}"), &collator);
-
- runQueryAsCommand(
- fromjson("{find: 'testns', min: {a: 1, b: 2}, max: {a: 1, b: 2}, "
- "projection: {_id: 0, a: 1, b: 1}, collation: {locale: 'reverse'}}"));
-
- assertNumSolutions(1U);
- assertSolutionExists(
- "{proj: {spec: {_id: 0, a: 1, b: 1}, node: {ixscan: {pattern: {a: 1, b: 1}}}}}");
-}
-
TEST_F(QueryPlannerTest, SimpleRegexCanUseAnIndexWithACollatorWithLooseBounds) {
CollatorInterfaceMock collator(CollatorInterfaceMock::MockType::kReverseString);
addIndex(fromjson("{a: 1}"), &collator);
diff --git a/src/mongo/db/query/query_planner_common.cpp b/src/mongo/db/query/query_planner_common.cpp
index e9eb4a6c094..337f3a045fc 100644
--- a/src/mongo/db/query/query_planner_common.cpp
+++ b/src/mongo/db/query/query_planner_common.cpp
@@ -71,7 +71,7 @@ void QueryPlannerCommon::reverseScans(QuerySolutionNode* node) {
}
if (!isn->bounds.isValidFor(isn->index.keyPattern, isn->direction)) {
- LOG(5) << "Invalid bounds: " << redact(isn->bounds.toString());
+ severe() << "Invalid bounds: " << redact(isn->bounds.toString());
MONGO_UNREACHABLE;
}
diff --git a/src/mongo/db/query/query_planner_test.cpp b/src/mongo/db/query/query_planner_test.cpp
index 5b650d6db21..5a3818d21cc 100644
--- a/src/mongo/db/query/query_planner_test.cpp
+++ b/src/mongo/db/query/query_planner_test.cpp
@@ -1113,12 +1113,7 @@ TEST_F(QueryPlannerTest, MaxValid) {
TEST_F(QueryPlannerTest, MinMaxSameValue) {
addIndex(BSON("a" << 1));
- runQueryHintMinMax(BSONObj(), BSONObj(), fromjson("{a: 1}"), fromjson("{a: 1}"));
-
- assertNumSolutions(1U);
- assertSolutionExists(
- "{fetch: {filter: null, "
- "node: {ixscan: {filter: null, pattern: {a: 1}}}}}");
+ runInvalidQueryHintMinMax(BSONObj(), BSONObj(), fromjson("{a: 1}"), fromjson("{a: 1}"));
}
TEST_F(QueryPlannerTest, MaxWithoutIndex) {