Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-19349

$type results are inconsistent with indexing enable on Infinity, -Infinity, NaN

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.1.7
    • Affects Version/s: 2.2.7, 2.4.14, 2.6.10, 3.1.5
    • Component/s: Index Maintenance, Querying
    • Minor Change
    • ALL
    • Hide

      In the shell:

      > db.test.insert({ a: Infinity })
      WriteResult({ "nInserted" : 1 })
      > db.test.find({ a : { $type : 1 }})
      { "_id" : ObjectId("559edd0837a9ccb7245bb7fd"), "a" : Infinity }
      > db.test.ensureIndex({ a : 1})
      {
              "createdCollectionAutomatically" : false,
              "numIndexesBefore" : 1,
              "numIndexesAfter" : 2,
              "ok" : 1
      }
      > db.test.find({ a : { $type : 1 }})
      > db.test.dropIndex({ a : 1 })
      { "nIndexesWas" : 2, "ok" : 1 }
      > db.test.find({ a : { $type : 1 }})
      { "_id" : ObjectId("559edd0837a9ccb7245bb7fd"), "a" : Infinity }
      
      Show
      In the shell: > db.test.insert({ a: Infinity }) WriteResult({ "nInserted" : 1 }) > db.test.find({ a : { $type : 1 }}) { "_id" : ObjectId( "559edd0837a9ccb7245bb7fd" ), "a" : Infinity } > db.test.ensureIndex({ a : 1}) { "createdCollectionAutomatically" : false , "numIndexesBefore" : 1, "numIndexesAfter" : 2, "ok" : 1 } > db.test.find({ a : { $type : 1 }}) > db.test.dropIndex({ a : 1 }) { "nIndexesWas" : 2, "ok" : 1 } > db.test.find({ a : { $type : 1 }}) { "_id" : ObjectId( "559edd0837a9ccb7245bb7fd" ), "a" : Infinity }

      Executing a type query with indexing and without can result in different results for Infinity, -Infinity, NaN.

      The issue is in src/mongo/db/query/index_bounds_builder.cpp and caused by implementation of BSONElement.appendMin/MaxForType.

            Assignee:
            david.hatch David Hatch
            Reporter:
            david.hatch David Hatch
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: