2013-11-27 10:35:45 -05:00
|
|
|
// make sure that we don't crash on large nested arrays but correctly do not index them
|
|
|
|
|
// SERVER-5127, SERVER-5036
|
2012-07-12 14:14:38 -04:00
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
function makeNestArr(depth) {
|
|
|
|
|
if (depth == 1) {
|
2016-05-28 17:55:12 -04:00
|
|
|
return {a: [depth]};
|
2016-03-09 12:17:50 -05:00
|
|
|
} else {
|
2016-05-28 17:55:12 -04:00
|
|
|
return {a: [makeNestArr(depth - 1)]};
|
2013-11-27 10:35:45 -05:00
|
|
|
}
|
2012-07-12 14:14:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
t = db.arrNestTest;
|
|
|
|
|
t.drop();
|
|
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
t.ensureIndex({a: 1});
|
2012-07-12 14:14:38 -04:00
|
|
|
|
2013-11-27 10:35:45 -05:00
|
|
|
n = 1;
|
2016-03-09 12:17:50 -05:00
|
|
|
while (true) {
|
2013-11-27 10:35:45 -05:00
|
|
|
var before = t.count();
|
2016-03-09 12:17:50 -05:00
|
|
|
t.insert({_id: n, a: makeNestArr(n)});
|
2013-11-27 10:35:45 -05:00
|
|
|
var after = t.count();
|
2016-03-09 12:17:50 -05:00
|
|
|
if (before == after)
|
2013-11-27 10:35:45 -05:00
|
|
|
break;
|
|
|
|
|
n++;
|
|
|
|
|
}
|
2012-07-12 14:14:38 -04:00
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
assert(n > 30, "not enough n: " + n);
|
2012-07-12 14:14:38 -04:00
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
assert.eq(t.count(), t.find({_id: {$gt: 0}}).hint({a: 1}).itcount());
|