Details
Description
Historically the shell has accepted a negative value for batchSize and passed this through to the server as a negative "ntoreturn" value. The query
db.collection.find().batchSize(-8);
|
means return up to 8 documents in the initial response batch, and then close the cursor.
When the shell is configured with --readMode commands, however, it currently passes the negative batchSize through to the server as a find command parameter. The server's find command implementation rejects negative batchSize:
> db.c.drop()
|
true
|
> db.c.insert({a: 1})
|
WriteResult({ "nInserted" : 1 })
|
> db.c.find().batchSize(-1)
|
Error: error: {
|
"waitedMS" : NumberLong(0),
|
"ok" : 0,
|
"errmsg" : "batchSize value must be non-negative",
|
"code" : 2
|
}
|
This behavior is inconsistent with the drivers find command specification for the behavior of limit, skip, and batchSize. Instead, the shell should translate a batchSize of -n to a batchSize of +n with the singleBatch option set to true.
Attachments
Issue Links
- is duplicated by
-
SERVER-24546 Explain() fails if negative batchSize value is specified
-
- Closed
-
- related to
-
RUBY-1147 Error when sending getMore command on 3.2 and limit or batchSize is 0
-
- Closed
-