diff options
author | Irina Yatsenko <irina.yatsenko@mongodb.com> | 2021-07-07 15:44:54 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-07-16 05:38:55 +0000 |
commit | beeab6beaf18232e52bb3094f5f31fe83fbae2a4 (patch) | |
tree | dce5b9fefa813283212757dcf16f59e4b8bffe9e /src/mongo/db/curop.cpp | |
parent | 23ecc48f89f4ec03d7b42e637c5969802efdb261 (diff) | |
download | mongo-beeab6beaf18232e52bb3094f5f31fe83fbae2a4.tar.gz |
SERVER-57391 Return error response to OP_QUERY and OP_GET_MORE messages
Diffstat (limited to 'src/mongo/db/curop.cpp')
-rw-r--r-- | src/mongo/db/curop.cpp | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/src/mongo/db/curop.cpp b/src/mongo/db/curop.cpp index 2ad744aefd5..aba407a169a 100644 --- a/src/mongo/db/curop.cpp +++ b/src/mongo/db/curop.cpp @@ -67,87 +67,12 @@ using std::string; namespace { -// Lists the $-prefixed query options that can be passed alongside a wrapped query predicate for -// OP_QUERY find. The $orderby field is omitted because "orderby" (no dollar sign) is also allowed, -// and this requires special handling. -const std::vector<const char*> kDollarQueryModifiers = { - "$hint", - "$comment", - "$max", - "$min", - "$returnKey", - "$showDiskLoc", - "$snapshot", - "$maxTimeMS", -}; - TimerStats oplogGetMoreStats; ServerStatusMetricField<TimerStats> displayBatchesReceived("repl.network.oplogGetMoresProcessed", &oplogGetMoreStats); } // namespace -BSONObj upconvertQueryEntry(const BSONObj& query, - const NamespaceString& nss, - int ntoreturn, - int ntoskip) { - BSONObjBuilder bob; - - bob.append("find", nss.coll()); - - // Whether or not the query predicate is wrapped inside a "query" or "$query" field so that - // other options can be passed alongside the predicate. - bool predicateIsWrapped = false; - - // Extract the query predicate. - BSONObj filter; - if (query["query"].isABSONObj()) { - predicateIsWrapped = true; - bob.appendAs(query["query"], "filter"); - } else if (query["$query"].isABSONObj()) { - predicateIsWrapped = true; - bob.appendAs(query["$query"], "filter"); - } else if (!query.isEmpty()) { - bob.append("filter", query); - } - - if (ntoskip) { - bob.append("skip", ntoskip); - } - if (ntoreturn) { - bob.append("ntoreturn", ntoreturn); - } - - // The remainder of the query options are only available if the predicate is passed in wrapped - // form. If the predicate is not wrapped, we're done. - if (!predicateIsWrapped) { - return bob.obj(); - } - - // Extract the sort. - if (auto elem = query["orderby"]) { - bob.appendAs(elem, "sort"); - } else if (auto elem = query["$orderby"]) { - bob.appendAs(elem, "sort"); - } - - // Add $-prefixed OP_QUERY modifiers, like $hint. - for (auto modifier : kDollarQueryModifiers) { - if (auto elem = query[modifier]) { - // Use "+ 1" to omit the leading dollar sign. - bob.appendAs(elem, modifier + 1); - } - } - - return bob.obj(); -} - -BSONObj upconvertGetMoreEntry(const NamespaceString& nss, CursorId cursorId, int ntoreturn) { - GetMoreCommandRequest getMoreRequest(cursorId, nss.coll().toString()); - getMoreRequest.setBatchSize(ntoreturn); - return getMoreRequest.toBSON({}); -} - /** * This type decorates a Client object with a stack of active CurOp objects. * |