diff options
author | Marko Vojvodic <marko.vojvodic@mongodb.com> | 2016-11-02 15:59:53 -0400 |
---|---|---|
committer | Marko Vojvodic <marko.vojvodic@mongodb.com> | 2016-11-04 15:40:04 -0400 |
commit | c1567abb4ace3e042931ae705d5b3afd8fbd750b (patch) | |
tree | b24dc0ec4e697fac25ad591310f8bd89a22d49e2 /jstests/aggregation/bugs | |
parent | a7f147affcc6fe1a751e71a7bff1ad417ddb3b84 (diff) | |
download | mongo-c1567abb4ace3e042931ae705d5b3afd8fbd750b.tar.gz |
SERVER-26462 Check if _buffer is allocated in DocumentStorage::clone()
Diffstat (limited to 'jstests/aggregation/bugs')
-rw-r--r-- | jstests/aggregation/bugs/server26462.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/jstests/aggregation/bugs/server26462.js b/jstests/aggregation/bugs/server26462.js new file mode 100644 index 00000000000..b0ef33ae35b --- /dev/null +++ b/jstests/aggregation/bugs/server26462.js @@ -0,0 +1,29 @@ +// Tests that adding a field that only contains metadata does not cause a segmentation fault when +// grouping on the added field. +(function() { + "use strict"; + + // Drop the old test collection, if any. + db.server26462.drop(); + + // Insert some test documents into the collection. + assert.writeOK(db.server26462.insert({"_id": 1, "title": "cakes and ale"})); + assert.writeOK(db.server26462.insert({"_id": 2, "title": "more cakes"})); + assert.writeOK(db.server26462.insert({"_id": 3, "title": "bread"})); + assert.writeOK(db.server26462.insert({"_id": 4, "title": "some cakes"})); + + // Create a text index on the documents. + assert.commandWorked(db.server26462.createIndex({title: "text"})); + + // Add a metadata only field in the aggregation pipeline and use that field in the $group _id. + let res = db.server26462 + .aggregate([ + {$match: {$text: {$search: "cake"}}}, + {$addFields: {fooScore: {$meta: "textScore"}}}, + {$group: {_id: "$fooScore", count: {$sum: 1}}} + ]) + .itcount(); + + // Assert that the command worked. + assert.eq(2, res); +})(); |