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

ensureIndex returns wrong error code for invalidate create index

    XMLWordPrintableJSON

Details

    • ALL
    • Hide

      From QA/QA-370
      /**
       * bad_index_tests.js
       * Make sure that we cannot build invalid indexes with the new external sort refactor.
       *
       * Note that all of these are large enough to trigger a spill to disk.
       *
       * NOTE: for text search to be indexed you need to it to be enabled on
       * mongod startup
       */
      coll = db.manyIndexType;
      coll.drop();
       
      //multi-key index (index on array)
      //could be smaller really...
      print("trying to create hashed multikey index...");
      for(i=0; i<50000; i++) {
          arr = [];
          for(j=0; j<(i/100); j++) {
              arr.push(j);
          }
          coll.insert({a: arr})
      }
      var err = coll.ensureIndex({a : "hashed"});
      assert.neq(err, undefined);
      assert.eq(coll.getIndexes().length, 1);
      assert.eq(err.code, 16766, "should not be able to create hashed multikey index");
      coll.drop();
      print("PASSED");

      Show
      From QA/QA-370 /** * bad_index_tests.js * Make sure that we cannot build invalid indexes with the new external sort refactor. * * Note that all of these are large enough to trigger a spill to disk. * * NOTE: for text search to be indexed you need to it to be enabled on * mongod startup */ coll = db.manyIndexType; coll.drop();   //multi-key index (index on array) //could be smaller really... print("trying to create hashed multikey index..."); for(i=0; i<50000; i++) { arr = []; for(j=0; j<(i/100); j++) { arr.push(j); } coll.insert({a: arr}) } var err = coll.ensureIndex({a : "hashed"}); assert.neq(err, undefined); assert.eq(coll.getIndexes().length, 1); assert.eq(err.code, 16766, "should not be able to create hashed multikey index"); coll.drop(); print("PASSED");

    Description

      When creating a hashed index over an array we get the wrong error code.

      Actual:

      WriteResult({
      	"nInserted" : 0,
      	"writeError" : {
      		"code" : 1,
      		"errmsg" : "Error: hashed indexes do not currently support array values"
      	}
      })

      Expected:

      WriteResult({
      	"nInserted" : 0,
      	"writeError" : {
      		"code" : 16766,
      		"errmsg" : "Error: hashed indexes do not currently support array values"
      	}
      })

      Attachments

        Activity

          People

            mark.benvenuto@mongodb.com Mark Benvenuto
            mark.benvenuto@mongodb.com Mark Benvenuto
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: