summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/index_bounds_builder_test.cpp
diff options
context:
space:
mode:
authorJacob Evans <jacob.evans@mongodb.com>2020-01-07 18:32:44 +0000
committerevergreen <evergreen@mongodb.com>2020-01-07 18:32:44 +0000
commit71658c0e2edb8c900ced5098f3f5a146a2d649ea (patch)
treef5e11b98193db35b68cbc0433bc729bf50d99d62 /src/mongo/db/query/index_bounds_builder_test.cpp
parent3be20276ea915648544367833f1c3e09764ea293 (diff)
downloadmongo-71658c0e2edb8c900ced5098f3f5a146a2d649ea.tar.gz
SERVER-45152 Demote invariant to massert to prevent server crashes
Diffstat (limited to 'src/mongo/db/query/index_bounds_builder_test.cpp')
-rw-r--r--src/mongo/db/query/index_bounds_builder_test.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/mongo/db/query/index_bounds_builder_test.cpp b/src/mongo/db/query/index_bounds_builder_test.cpp
index 2d3ca2d0ac5..7ec1beb9f37 100644
--- a/src/mongo/db/query/index_bounds_builder_test.cpp
+++ b/src/mongo/db/query/index_bounds_builder_test.cpp
@@ -492,6 +492,32 @@ TEST_F(IndexBoundsBuilderTest, TranslateGtMinKey) {
ASSERT_EQUALS(tightness, IndexBoundsBuilder::EXACT);
}
+TEST_F(IndexBoundsBuilderTest, DontCrashOnNegationOfArrayInequality) {
+ BSONObj keyPattern = BSON("a" << 1);
+ auto testIndex = IndexEntry(keyPattern,
+ IndexNames::nameToType(IndexNames::findPluginName(keyPattern)),
+ true, // multikey
+ {},
+ {},
+ false, // sparse
+ false, // unique
+ IndexEntry::Identifier{"test_foo"},
+ nullptr, // filterExpr
+ BSONObj(),
+ nullptr,
+ nullptr);
+
+ BSONObj obj = fromjson("{a: {$not: {$lt: [\"here\", {}, false]}}}");
+ auto expr = MatchExpression::optimize(parseMatchExpression(obj));
+ BSONElement elt = obj.firstElement();
+ OrderedIntervalList oil;
+ IndexBoundsBuilder::BoundsTightness tightness;
+ // TODO: SERVER-45233 This should succeed rather than throwing code.
+ ASSERT_THROWS_CODE(IndexBoundsBuilder::translate(expr.get(), elt, testIndex, &oil, &tightness),
+ DBException,
+ ErrorCodes::InternalError);
+}
+
// Nothing can be greater than MaxKey so the resulting index bounds would be a useless empty range.
TEST_F(IndexBoundsBuilderTest, TranslateGtMaxKeyDoesNotGenerateBounds) {
auto testIndex = buildSimpleIndexEntry();