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

Indexed and non-indexed collections return different results for null query

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.2.10, 4.7.0, 4.4.2
    • Component/s: None
    • Labels:
    • Backwards Compatibility:
      Minor Change
    • Operating System:
      ALL
    • Backport Requested:
      v4.4, v4.2
    • Sprint:
      Query 2020-08-10, Query 2020-08-24, Query 2020-09-07, Query 2020-09-21
    • Linked BF Score:
      41

      Description

      The collection index has an index on the val field.

      > db.index.find({val: {$not: {$gte: null}}})
      > db.non.find({val: {$not: {$gte: null}}})
      { "_id" : ObjectId("5f16f0bb1fe2fb0ca7b13d12"), "val" : [ ] }
      > db.index.find()
      { "_id" : ObjectId("5f16f0da1fe2fb0ca7b13d13"), "val" : [ ] }
      { "_id" : ObjectId("5f16ff661fe2fb0ca7b13d14"), "val" : null }
      > db.non.find()
      { "_id" : ObjectId("5f16f0bb1fe2fb0ca7b13d12"), "val" : [ ] }
      { "_id" : ObjectId("5f16ff6d1fe2fb0ca7b13d15"), "val" : null }
      > db.index.getIndexes()
      [
              {
                      "v" : 2,
                      "key" : {
                              "_id" : 1
                      },
                      "name" : "_id_"
              },
              {
                      "v" : 2,
                      "key" : {
                              "val" : 1
                      },
                      "name" : "val_1"
              }
      ]
      > db.non.getIndexes()
      [ { "v" : 2, "key" : { "_id" : 1 }, "name" : "_id_" } ]

      The problem is probably in this function complement, called from here 

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              svilen.mihaylov Svilen Mihaylov
              Reporter:
              ted.tuckman Ted Tuckman
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              11 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: