summaryrefslogtreecommitdiff
path: root/jstests/long_index_rename.js
blob: 41e1bfd4a3b12e2c8330aea91cfcf0a6b56a3eb2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// 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( result.code >= 0 );
assert( result.err.indexOf( "too long" ) >= 0 );