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

Creating a compound sparse index should uassert

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Index Maintenance
    • None

      It looks like there's a uassert in indexkey.cpp, but it isn't correct. I think it should be:

      uassert( 13529 , "sparse only works for single field keys" , ! _sparse || _nFields == 1 );

      Example:

      admin> db.foo.ensureIndex(

      {x:1,y:1}

      ,

      {sparse:true,unique:true}

      )
      admin> db.foo.getIndexes()
      [
      {
      "v" : 1,
      "key" :

      { "_id" : 1 }

      ,
      "ns" : "admin.foo",
      "name" : "id"
      },
      {
      "v" : 1,
      "key" :

      { "x" : 1, "y" : 1 }

      ,
      "unique" : true,
      "ns" : "admin.foo",
      "name" : "x_1_y_1",
      "sparse" : true
      }
      ]

            Assignee:
            randolph@mongodb.com Randolph Tan
            Reporter:
            kristina Kristina Chodorow (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: