Skip to content

Commit cbbfdad

Browse files
author
Hari Khalsa
committed
SERVER-10026 clean up LiteParsedQuery, tunnel switch through dbtest, fix naming error in planner
1 parent 9c4e270 commit cbbfdad

File tree

9 files changed

+246
-212
lines changed

9 files changed

+246
-212
lines changed

src/mongo/db/clientcursor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ namespace mongo {
143143

144144
for (set<Runner*>::iterator it = nonCachedRunners.begin(); it != nonCachedRunners.end(); ++it) {
145145
Runner* runner = *it;
146-
const char* runnerNS = runner->getQuery().getParsed().ns();
147-
if ((isDB && str::startsWith(runnerNS, ns)) || (str::equals(runnerNS, ns))) {
146+
const string& runnerNS = runner->getQuery().getParsed().ns();
147+
if ((isDB && str::startsWith(runnerNS, ns)) || (str::equals(runnerNS.c_str(), ns))) {
148148
runner->kill();
149149
}
150150
}

src/mongo/db/query/canonical_query.cpp

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,18 @@
2222
namespace mongo {
2323

2424
// static
25-
Status CanonicalQuery::canonicalize(QueryMessage& qm, CanonicalQuery** out) {
25+
Status CanonicalQuery::canonicalize(const QueryMessage& qm, CanonicalQuery** out) {
2626
auto_ptr<CanonicalQuery> cq(new CanonicalQuery());
2727

28-
// TODO: LiteParsedQuery throws. Fix it to return error.
29-
cq->_pq.reset(new LiteParsedQuery(qm));
30-
31-
// TODO: If pq.hasOption(QueryOption_CursorTailable) make sure it's a capped collection and
32-
// make sure the order(??) is $natural: 1.
33-
34-
// TODO: Do we want to do this too?:
35-
//if ( pq.getFields() != NULL )
36-
// pq.getFields()->validateQuery( query );
28+
// Parse the query.
29+
LiteParsedQuery* lpq;
30+
Status parseStatus = LiteParsedQuery::make(qm, &lpq);
31+
if (!parseStatus.isOK()) { return parseStatus; }
32+
cq->_pq.reset(lpq);
3733

34+
// Build a parse tree from the BSONObj in the parsed query.
3835
StatusWithMatchExpression swme = MatchExpressionParser::parse(cq->_pq->getFilter());
39-
if (!swme.isOK()) {
40-
return swme.getStatus();
41-
}
36+
if (!swme.isOK()) { return swme.getStatus(); }
4237

4338
cq->_root.reset(swme.getValue());
4439
*out = cq.release();
@@ -49,11 +44,10 @@ namespace mongo {
4944
CanonicalQuery** out) {
5045
auto_ptr<CanonicalQuery> cq(new CanonicalQuery());
5146

52-
// LiteParsedQuery saves the pointer to the NS that we provide it. It's not going to remain
53-
// valid unless we cache it ourselves.
54-
cq->_ns = ns;
55-
56-
cq->_pq.reset(new LiteParsedQuery(cq->_ns.c_str(), 0, 0, 0, query));
47+
LiteParsedQuery* lpq;
48+
Status parseStatus = LiteParsedQuery::make(ns, 0, 0, 0, query, &lpq);
49+
if (!parseStatus.isOK()) { return parseStatus; }
50+
cq->_pq.reset(lpq);
5751

5852
StatusWithMatchExpression swme = MatchExpressionParser::parse(cq->_pq->getFilter());
5953
if (!swme.isOK()) { return swme.getStatus(); }

src/mongo/db/query/canonical_query.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,13 @@ namespace mongo {
2626

2727
class CanonicalQuery {
2828
public:
29-
// TODO: qm is mutable because LiteParsedQuery wants it mutable. FIX.
30-
static Status canonicalize(QueryMessage& qm, CanonicalQuery** out);
29+
static Status canonicalize(const QueryMessage& qm, CanonicalQuery** out);
3130

3231
// This is for testing, when we don't have a QueryMessage.
3332
static Status canonicalize(const string& ns, const BSONObj& query, CanonicalQuery** out);
3433

3534
// What namespace is this query over?
36-
const char* ns() const { return _pq->ns(); }
35+
const string& ns() const { return _pq->ns(); }
3736

3837
//
3938
// Accessors for the query
@@ -52,8 +51,6 @@ namespace mongo {
5251

5352
// _root points into _pq->getFilter()
5453
scoped_ptr<MatchExpression> _root;
55-
56-
string _ns;
5754
};
5855

5956
} // namespace mongo

0 commit comments

Comments
 (0)