summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/canonical_query_encoder.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/query/canonical_query_encoder.cpp')
-rw-r--r--src/mongo/db/query/canonical_query_encoder.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/mongo/db/query/canonical_query_encoder.cpp b/src/mongo/db/query/canonical_query_encoder.cpp
index 4313b6efc2b..d86eb8ab37b 100644
--- a/src/mongo/db/query/canonical_query_encoder.cpp
+++ b/src/mongo/db/query/canonical_query_encoder.cpp
@@ -86,7 +86,7 @@ const char kEncodeProjectionSection = '|';
const char kEncodeProjectionRequirementSeparator = '-';
const char kEncodeRegexFlagsSeparator = '/';
const char kEncodeSortSection = '~';
-const char kEncodeEngineSection = '@';
+const char kEncodeFlagsSection = '@';
const char kEncodePipelineSection = '^';
// These special bytes are used in the encoding of auto-parameterized match expressions in the SBE
@@ -134,7 +134,7 @@ void encodeUserString(StringData s, BuilderType* builder) {
case kEncodeProjectionRequirementSeparator:
case kEncodeRegexFlagsSeparator:
case kEncodeSortSection:
- case kEncodeEngineSection:
+ case kEncodeFlagsSection:
case kEncodeParamMarker:
case kEncodeConstantLiteralMarker:
case kEncodePipelineSection:
@@ -701,7 +701,13 @@ CanonicalQuery::QueryShapeString encode(const CanonicalQuery& cq) {
// This encoding can be removed once the classic query engine reaches EOL and SBE is used
// exclusively for all query execution.
- keyBuilder << kEncodeEngineSection << (cq.getForceClassicEngine() ? "f" : "t");
+ keyBuilder << kEncodeFlagsSection << (cq.getForceClassicEngine() ? "f" : "t");
+
+ // The apiStrict flag can cause the query to see different set of indexes. For example, all
+ // sparse indexes will be ignored with apiStrict is used.
+ const bool apiStrict =
+ cq.getOpCtx() && APIParameters::get(cq.getOpCtx()).getAPIStrict().value_or(false);
+ keyBuilder << (apiStrict ? "t" : "f");
return keyBuilder.str();
}
@@ -1114,6 +1120,11 @@ std::string encodeSBE(const CanonicalQuery& cq) {
bufBuilder.appendStr(strBuilderEncoded, false /* includeEndingNull */);
bufBuilder.appendChar(cq.getForceGenerateRecordId() ? 1 : 0);
bufBuilder.appendChar(cq.isCountLike() ? 1 : 0);
+ // The apiStrict flag can cause the query to see different set of indexes. For example, all
+ // sparse indexes will be ignored with apiStrict is used.
+ const bool apiStrict =
+ cq.getOpCtx() && APIParameters::get(cq.getOpCtx()).getAPIStrict().value_or(false);
+ bufBuilder.appendChar(apiStrict ? 1 : 0);
encodeFindCommandRequest(cq.getFindCommandRequest(), &bufBuilder);