summaryrefslogtreecommitdiff
path: root/jstests/long_index_rename.js
blob: 80dbe2749ff6f2f445041d367f670bac0c1f84f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// SERVER-7720 Building an index with a too-long name should always fail
// Formerly, we would allow an index that already existed to be "created" with too long a name,
// but this caused secondaries to crash when replicating what should be a bad createIndex command.
// Here we test that the too-long name is rejected in this situation as well

t = db.long_index_rename;
t.drop();

for (i = 1; i < 10; i++) {
    t.save({a:i});
}

t.createIndex({a:1}, {name: "aaa"});
t.createIndex({a:1}, {name: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
                            "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"});
var result = db.getLastErrorObj();
assert.eq(result.code, 16829);