diff --git a/db/queryutil.cpp b/db/queryutil.cpp index 4d45a3b6326..b06a3f32edf 100644 --- a/db/queryutil.cpp +++ b/db/queryutil.cpp @@ -119,6 +119,8 @@ namespace mongo { BSONElement e = i.next(); if ( e.eoo() ) break; + if ( strcmp( e.fieldName(), "$where" ) == 0 ) + continue; if ( getGtLtOp( e ) == JSMatcher::Equality ) { bounds_[ e.fieldName() ] &= FieldBound( e ); } diff --git a/dbtests/queryoptimizertests.cpp b/dbtests/queryoptimizertests.cpp index 5ea12900d69..d3639864663 100644 --- a/dbtests/queryoptimizertests.cpp +++ b/dbtests/queryoptimizertests.cpp @@ -189,6 +189,13 @@ namespace QueryOptimizerTests { } }; + class NoWhere { + public: + void run() { + ASSERT_EQUALS( 0, FieldBoundSet( "ns", BSON( "$where" << 1 ) ).nNontrivialBounds() ); + } + }; + } // namespace FieldBoundTests namespace QueryPlanTests { @@ -830,6 +837,7 @@ namespace QueryOptimizerTests { add< FieldBoundTests::In >(); add< FieldBoundTests::SimplifiedQuery >(); add< FieldBoundTests::QueryPatternTest >(); + add< FieldBoundTests::NoWhere >(); add< QueryPlanTests::NoIndex >(); add< QueryPlanTests::SimpleOrder >(); add< QueryPlanTests::MoreIndexThanNeeded >(); diff --git a/mongo.xcodeproj/project.pbxproj b/mongo.xcodeproj/project.pbxproj index 906516f748e..cf315f1d509 100644 --- a/mongo.xcodeproj/project.pbxproj +++ b/mongo.xcodeproj/project.pbxproj @@ -22,6 +22,13 @@ 9302D9A20F30AB8C00DFA4EF /* utils.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = utils.js; sourceTree = ""; }; 932AC3EB0F4A5B34005BF8B0 /* queryoptimizertests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = queryoptimizertests.cpp; sourceTree = ""; }; 932AC4310F4A5E9D005BF8B0 /* SConstruct */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SConstruct; sourceTree = ""; }; + 933A4D130F55A68600145C4B /* authTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = authTest.cpp; sourceTree = ""; }; + 933A4D150F55A68600145C4B /* clientTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = clientTest.cpp; sourceTree = ""; }; + 933A4D170F55A68600145C4B /* first.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = first.cpp; sourceTree = ""; }; + 933A4D190F55A68600145C4B /* second.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = second.cpp; sourceTree = ""; }; + 933A4D1B0F55A68600145C4B /* tail.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = tail.cpp; sourceTree = ""; }; + 933A4D1C0F55A68600145C4B /* tutorial.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = tutorial.cpp; sourceTree = ""; }; + 933A4D1D0F55A68600145C4B /* whereExample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = whereExample.cpp; sourceTree = ""; }; 933E22110F4327B2000209E3 /* perftest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = perftest.cpp; sourceTree = ""; }; 933E22120F4327B2000209E3 /* perftest.o */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.objfile"; path = perftest.o; sourceTree = ""; }; 9342232B0EF16D4F00608550 /* connpool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = connpool.cpp; sourceTree = ""; }; @@ -293,6 +300,20 @@ path = shell; sourceTree = ""; }; + 933A4D120F55A68600145C4B /* examples */ = { + isa = PBXGroup; + children = ( + 933A4D130F55A68600145C4B /* authTest.cpp */, + 933A4D150F55A68600145C4B /* clientTest.cpp */, + 933A4D170F55A68600145C4B /* first.cpp */, + 933A4D190F55A68600145C4B /* second.cpp */, + 933A4D1B0F55A68600145C4B /* tail.cpp */, + 933A4D1C0F55A68600145C4B /* tutorial.cpp */, + 933A4D1D0F55A68600145C4B /* whereExample.cpp */, + ); + path = examples; + sourceTree = ""; + }; 933E22100F4327B2000209E3 /* perf */ = { isa = PBXGroup; children = ( @@ -305,6 +326,7 @@ 9342232A0EF16D4F00608550 /* client */ = { isa = PBXGroup; children = ( + 933A4D120F55A68600145C4B /* examples */, 9342232B0EF16D4F00608550 /* connpool.cpp */, 9342232C0EF16D4F00608550 /* connpool.h */, 9342232D0EF16D4F00608550 /* dbclient.cpp */,