diff options
Diffstat (limited to 'src/mongo/db/matcher/rewrite_expr.cpp')
| -rw-r--r-- | src/mongo/db/matcher/rewrite_expr.cpp | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/src/mongo/db/matcher/rewrite_expr.cpp b/src/mongo/db/matcher/rewrite_expr.cpp index 4f44cd269ef..e61ddeaab78 100644 --- a/src/mongo/db/matcher/rewrite_expr.cpp +++ b/src/mongo/db/matcher/rewrite_expr.cpp @@ -45,7 +45,7 @@ using CmpOp = ExpressionCompare::CmpOp; RewriteExpr::RewriteResult RewriteExpr::rewrite(const boost::intrusive_ptr<Expression>& expression, const CollatorInterface* collator) { LOGV2_DEBUG( - 20725, 5, "Expression prior to rewrite", "expression"_attr = expression->serialize()); + 20725, 5, "Expression prior to rewrite", "expression"_attr = expression->serialize(false)); RewriteExpr rewriteExpr(collator); std::unique_ptr<MatchExpression> matchExpression; @@ -63,9 +63,7 @@ RewriteExpr::RewriteResult RewriteExpr::rewrite(const boost::intrusive_ptr<Expre "expression"_attr = matchExpression->debugString()); } - return {std::move(matchExpression), - std::move(rewriteExpr._matchExprElemStorage), - rewriteExpr._allSubExpressionsRewritten}; + return {std::move(matchExpression), std::move(rewriteExpr._matchExprElemStorage)}; } std::unique_ptr<MatchExpression> RewriteExpr::_rewriteExpression( @@ -88,11 +86,8 @@ std::unique_ptr<MatchExpression> RewriteExpr::_rewriteAndExpression( auto andMatch = std::make_unique<AndMatchExpression>(); for (auto&& child : currExprNode->getOperandList()) - if (auto childMatch = _rewriteExpression(child)) { + if (auto childMatch = _rewriteExpression(child)) andMatch->add(std::move(childMatch)); - } else { - _allSubExpressionsRewritten = false; - } if (andMatch->numChildren() > 0) return andMatch; @@ -107,12 +102,10 @@ std::unique_ptr<MatchExpression> RewriteExpr::_rewriteOrExpression( for (auto&& child : currExprNode->getOperandList()) if (auto childExpr = _rewriteExpression(child)) orMatch->add(std::move(childExpr)); - else { + else // If any child cannot be rewritten to a MatchExpression then we must abandon adding // this $or clause. - _allSubExpressionsRewritten = false; return nullptr; - } if (orMatch->numChildren() > 0) return orMatch; |
