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

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Done
    • 2.2.7, 2.4.14, 2.6.10, 3.1.5
    • 3.1.7
    • 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 }

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: