[SERVER-12463] $not with certain indexes against null fields returns different results in 2.4 vs 2.5.5-pre Created: 23/Jan/14  Updated: 10/Dec/14  Resolved: 26/Jan/14

Status: Closed
Project: Core Server
Component/s: Index Maintenance, Querying
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Andrew Emil (Inactive) Assignee: Unassigned
Resolution: Done Votes: 0
Labels: 26qa
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Backwards Compatibility: Major Change
Operating System: ALL
Participants:

 Description   

Seems like in 2.4 with certain indexes enabled the results returned from $not against empty fields changes. This behavior is not continued in 2.5, which is probably correct.

In 2.5:

> db.rep.insert({_id:0})
SingleWriteResult({
        "writeErrors" : [ ],
        "writeConcernErrors" : [ ],
        "nInserted" : 1,
        "nUpserted" : 0,
        "nUpdated" : 0,
        "nModified" : 0,
        "nRemoved" : 0,
        "upserted" : [ ]
})
> db.rep.find({a:{$not: {$gt:1}}})
{ "_id" : 0 }
> db.rep.ensureIndex({a:1})
> db.rep.find({a:{$not: {$gt:1}}})
{ "_id" : 0 }
> db.runCommand({buildinfo:1})
{
        "version" : "2.5.5-pre-",
        "gitVersion" : "f65a0b814b8c77e3fbe90bca0c061c9b77f6acdb",
        "OpenSSLVersion" : "",
        "sysInfo" : "Darwin Andrew-Emil-MacBook-Pro.local 12.4.0 Darwin Kernel Version 12.4.0: Wed May  1 17:57:12 PDT 2013; root:xnu-2050.24.15~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49",
        "loaderFlags" : "-fPIC -pthread -Wl,-bind_at_load -mmacosx-version-min=10.6",
        "compilerFlags" : "-Wnon-virtual-dtor -Woverloaded-virtual -fPIC -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -Werror -pipe -O3 -Wno-unused-function -Wno-deprecated-declarations -mmacosx-version-min=10.6",
        "allocator" : "tcmalloc",
        "versionArray" : [
                2,
                5,
                5,
                -100
        ],
        "javascriptEngine" : "V8",
        "bits" : 64,
        "debug" : false,
        "maxBsonObjectSize" : 16777216,
        "ok" : 1
}

In 2.4:

> mydb.rep.insert({_id:0})
> mydb.rep.find({a:{$not: {$gt:1}}})
{ "_id" : 0 }
> mydb.rep.ensureIndex({a:1})
> mydb.rep.find({a:{$not: {$gt:1}}})
>



 Comments   
Comment by Andrew Emil (Inactive) [ 24/Jan/14 ]

Seems to also effect $ne and $nin queries, though I have not looked into this closely

EDIT: could not replicate this, I guess it works fine with $ne and $nin

Generated at Thu Feb 08 03:28:36 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.