|
The wire protocol documentation for OP_GET_MORE (https://docs.mongodb.com/manual/reference/mongodb-wire-protocol/#wire-op-get-more) says the following about numberToReturn:
Limits the number of documents in the first OP_REPLY message to the query. However, the database will still establish a cursor and return the cursorID to the client if there are more results than numberToReturn. If the client driver offers ‘limit’ functionality (like the SQL LIMIT keyword), then it is up to the client driver to ensure that no more than the specified number of document are returned to the calling application. If numberToReturn is 0, the db will used the default return size.
This should be extended to mention that numberToReturn should be non-negative. In version 3.3.1, under SERVER-20808, we added validation which will cause the server to return an error if it receives an OP_GET_MORE with a negative numberToReturn. Previous versions of the server did not implement valid semantics for negative numberToReturn, but also failed to reject it.
|