The following issues were found
src/mongo/db/query/plan_explainer_sbe.cpp
1 issues
Line: 311
CWE codes:
476
if (verbosity >= ExplainOptions::Verbosity::kExecStats) {
auto summary = collectExecutionStatsSummary(stats);
if (verbosity >= ExplainOptions::Verbosity::kExecAllPlans) {
summary.score = solution->score;
}
statsToBSON(stats, &bob, &bob);
// At the 'kQueryPlanner' verbosity level we use the QSN-derived format for the given plan,
// and thus the winning plan and rejected plans at this verbosity should display the
// stringified SBE plan, which is added below. However, at the 'kExecStats' the execution
Reported by Cppcheck.
src/mongo/db/query/plan_ranker.cpp
1 issues
Line: 81
CWE codes:
587
2,
"Scoring query plan",
"planSummary"_attr = planSummary(),
"planHitEOF"_attr = isEOF);
}
void logScore(double score) {
LOGV2_DEBUG(20958, 5, "Basic plan score", "score"_attr = score);
}
Reported by Cppcheck.
src/mongo/db/query/plan_ranker_test.cpp
1 issues
Line: 57
return stats;
}
TEST(PlanRankerTest, NoFetchBonus) {
// Two plans: one does a fetch, one does not. Assert the plan without the fetch has a higher
// score. Note there is no projection involved: before SERVER-39241 was fixed we would give
// these two plans the same score.
auto goodPlan =
Reported by Cppcheck.
src/mongo/db/query/planner_access_test.cpp
1 issues
Line: 46
return builder.obj();
}
TEST(PlannerAccessTest, PrepareForAccessPlanningSortsEqualNodesByTheirChildren) {
boost::intrusive_ptr<ExpressionContext> expCtx{new ExpressionContextForTest()};
Matcher matcher{fromjson("{$or: [{x: 1, b: 1}, {y: 1, a: 1}]}"), expCtx};
// Before sorting for access planning, the order of the tree should be as specified in the
// original input BSON.
ASSERT_BSONOBJ_EQ(serializeMatcher(&matcher),
Reported by Cppcheck.
src/mongo/db/query/planner_analysis_test.cpp
1 issues
Line: 63
nullptr};
}
TEST(QueryPlannerAnalysis, GetSortPatternBasic) {
ASSERT_BSONOBJ_EQ(fromjson("{a: 1}"), QueryPlannerAnalysis::getSortPattern(fromjson("{a: 1}")));
ASSERT_BSONOBJ_EQ(fromjson("{a: -1}"),
QueryPlannerAnalysis::getSortPattern(fromjson("{a: -1}")));
ASSERT_BSONOBJ_EQ(fromjson("{a: 1, b: 1}"),
QueryPlannerAnalysis::getSortPattern(fromjson("{a: 1, b: 1}")));
Reported by Cppcheck.
src/mongo/db/query/projection_ast_test.cpp
1 issues
Line: 99
ASSERT_BSONOBJ_EQ(cloneBSON, cloneBSON2);
}
TEST_F(ProjectionASTTest, TestParsingTypeEmptyProjectionIsExclusionInFind) {
Projection proj = parseWithFindFeaturesEnabled(fromjson("{}"));
ASSERT(proj.type() == ProjectType::kExclusion);
}
TEST_F(ProjectionASTTest, TestParsingTypeEmptyProjectionFailsInAggregation) {
ASSERT_THROWS_CODE(parseWithDefaultPolicies(fromjson("{}")), AssertionException, 51272);
Reported by Cppcheck.
src/mongo/db/query/projection_test.cpp
1 issues
Line: 101
errCode);
}
TEST(QueryProjectionTest, MakeEmptyProjection) {
ASSERT_THROWS_CODE(createProjection("{}", "{}"), AssertionException, 51272);
}
TEST(QueryProjectionTest, MakeEmptyFindProjection) {
Projection proj(createFindProjection("{}", "{}"));
Reported by Cppcheck.
src/mongo/db/query/query_planner_array_test.cpp
1 issues
Line: 41
using namespace mongo;
TEST_F(QueryPlannerTest, ElemMatchOneField) {
addIndex(BSON("a.b" << 1));
runQuery(fromjson("{a : {$elemMatch: {b:1}}}"));
ASSERT_EQUALS(getNumSolutions(), 2U);
assertSolutionExists("{cscan: {dir: 1, filter: {a:{$elemMatch:{b:1}}}}}");
Reported by Cppcheck.
src/mongo/db/query/query_planner_collation_test.cpp
1 issues
Line: 39
using namespace mongo;
TEST_F(QueryPlannerTest, StringComparisonWithNullCollatorOnIndexResultsInCollscan) {
addIndex(fromjson("{a: 1}"));
runQueryAsCommand(
fromjson("{find: 'testns', filter: {a: {$lt: 'foo'}}, collation: {locale: 'reverse'}}"));
Reported by Cppcheck.
src/mongo/db/query/query_planner_geo_test.cpp
1 issues
Line: 41
using namespace mongo;
TEST_F(QueryPlannerTest, Basic2DNonNear) {
// 2d can answer: within poly, within center, within centersphere, within box.
// And it can use an index (or not) for each of them. As such, 2 solns expected.
addIndex(BSON("a"
<< "2d"));
Reported by Cppcheck.