summaryrefslogtreecommitdiff
path: root/src/mongo/db/dbdirectclient.cpp
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2014-09-30 09:25:13 -0400
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2014-10-01 15:18:14 -0400
commitab4c908febe7c3b59263522949ee6a33aa40c0ab (patch)
tree23987c00f285cdf513efc8c1a6eaa469df3df622 /src/mongo/db/dbdirectclient.cpp
parent26ae74c6e9e5ec7c1a9d4715158593d2127e7dad (diff)
downloadmongo-ab4c908febe7c3b59263522949ee6a33aa40c0ab.tar.gz
SERVER-13522 Remove usages of runCount and replace them with DBDirectClient::count
Diffstat (limited to 'src/mongo/db/dbdirectclient.cpp')
-rw-r--r--src/mongo/db/dbdirectclient.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/mongo/db/dbdirectclient.cpp b/src/mongo/db/dbdirectclient.cpp
index 8be0a50519d..3bd49f839fa 100644
--- a/src/mongo/db/dbdirectclient.cpp
+++ b/src/mongo/db/dbdirectclient.cpp
@@ -29,7 +29,6 @@
#include "mongo/db/dbdirectclient.h"
#include "mongo/db/client.h"
-#include "mongo/db/commands/count.h"
#include "mongo/db/instance.h"
#include "mongo/db/operation_context.h"
#include "mongo/util/log.h"
@@ -166,32 +165,38 @@ namespace mongo {
const HostAndPort DBDirectClient::dummyHost("0.0.0.0", 0);
+ extern long long runCount(OperationContext* txn,
+ const string& ns,
+ const BSONObj &cmd,
+ string &err,
+ int &errCode);
+
unsigned long long DBDirectClient::count(const string& ns,
const BSONObj& query,
int options,
int limit,
int skip) {
+
if (skip < 0) {
warning() << "setting negative skip value: " << skip
- << " to zero in query: " << query << endl;
+ << " to zero in query: " << query << endl;
skip = 0;
}
- Lock::DBRead lk(_txn->lockState(), ns);
string errmsg;
int errCode;
long long res = runCount(_txn,
- ns,
- _countCmd(ns, query, options, limit, skip),
- errmsg,
- errCode);
+ ns,
+ _countCmd(ns, query, options, limit, skip),
+ errmsg,
+ errCode);
if (res == -1) {
// namespace doesn't exist
return 0;
}
- massert(errCode, str::stream() << "count failed in DBDirectClient: " << errmsg , res >= 0);
- return (unsigned long long )res;
+ massert(errCode, str::stream() << "count failed in DBDirectClient: " << errmsg, res >= 0);
+ return (unsigned long long)res;
}
} // namespace mongo