Details
-
Bug
-
Resolution: Done
-
Major - P3
-
None
-
None
-
Major Change
Description
Given a single cursor, iterator construction and iteration result in the construction of bsoncxx::document::view objects wrapping the bson_t pointer returned by a call to mongoc_cursor_next. However, the validity of this bson_t pointer is only until the next call to mongoc_cursor_next (see docs).
Consider this example:
auto cursor = db["fo"].find({});
|
auto iter1 = cursor.begin(); // Calls mongoc_cursor_next().
|
auto iter2 = cursor.begin(); // Calls mongoc_cursor_next().
|
|
|
// At this point, iter1._doc violates the lifecycle constraints.
|
|
|
iter1++;
|
|
|
// At this point, iter2._doc violates the lifecycle constraints.
|
In short, only the most recently iterated iterator ever has a valid bsoncxx::document::view.
Attachments
Issue Links
- is related to
-
CXX-1001 mongocxx::cursor.begin() increments the iterator
-
- Closed
-
-
CDRIVER-1886 Expose mongoc_cursor_t 'sent' field
-
- Closed
-