summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/optimizer/explain.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/query/optimizer/explain.cpp')
-rw-r--r--src/mongo/db/query/optimizer/explain.cpp28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/mongo/db/query/optimizer/explain.cpp b/src/mongo/db/query/optimizer/explain.cpp
index ba5aecdbd73..5e9df5df3bb 100644
--- a/src/mongo/db/query/optimizer/explain.cpp
+++ b/src/mongo/db/query/optimizer/explain.cpp
@@ -496,7 +496,7 @@ private:
void addValue(sbe::value::TypeTags tag, sbe::value::Value val, const bool append = false) {
if (!_initialized) {
_initialized = true;
- _canAppend = !_nextFieldName.empty();
+ _canAppend = _nextFieldName.has_value();
if (_canAppend) {
std::tie(_tag, _val) = sbe::value::makeNewObject();
} else {
@@ -512,7 +512,7 @@ private:
}
if (append) {
- uassert(6624073, "Field name is not empty", _nextFieldName.empty());
+ uassert(6624073, "Field name is not set", !_nextFieldName.has_value());
uassert(6624349,
"Other printer does not contain Object",
tag == sbe::value::TypeTags::Object);
@@ -523,19 +523,19 @@ private:
addField(obj->field(i), fieldTag, fieldVal);
}
} else {
- addField(_nextFieldName, tag, val);
- _nextFieldName.clear();
+ tassert(6751700, "Missing field name to serialize", _nextFieldName);
+ addField(*_nextFieldName, tag, val);
+ _nextFieldName = boost::none;
}
}
void addField(const std::string& fieldName, sbe::value::TypeTags tag, sbe::value::Value val) {
- uassert(6624074, "Field name is empty", !fieldName.empty());
uassert(6624075, "Duplicate field name", _fieldNameSet.insert(fieldName).second);
sbe::value::getObjectView(_val)->push_back(fieldName, tag, val);
}
void reset() {
- _nextFieldName.clear();
+ _nextFieldName = boost::none;
_initialized = false;
_canAppend = false;
_tag = sbe::value::TypeTags::Nothing;
@@ -543,7 +543,8 @@ private:
_fieldNameSet.clear();
}
- std::string _nextFieldName;
+ // Cannot assume empty means non-existent, so use optional<>.
+ boost::optional<std::string> _nextFieldName;
bool _initialized;
bool _canAppend;
sbe::value::TypeTags _tag;
@@ -1276,8 +1277,6 @@ public:
printer.separator(" [")
.fieldName("scanProjectionName", ExplainVersion::V3)
.print(node.getScanProjectionName());
- printBooleanFlag(printer, "hasLeftIntervals", node.hasLeftIntervals());
- printBooleanFlag(printer, "hasRightIntervals", node.hasRightIntervals());
printer.separator("]");
nodeCEPropsPrint(printer, n, node);
@@ -1766,6 +1765,7 @@ public:
.fieldName("scanDefName")
.print(prop.getScanDefName());
printBooleanFlag(printer, "eqPredsOnly", prop.getEqPredsOnly());
+ printBooleanFlag(printer, "hasProperInterval", prop.hasProperInterval());
printer.separator("]");
if (!prop.getSatisfiedPartialIndexes().empty()) {
@@ -2263,7 +2263,7 @@ public:
ExplainPrinter printer("PathGet");
printer.separator(" [")
.fieldName("path", ExplainVersion::V3)
- .print(path.name())
+ .print(path.name().empty() ? "<empty>" : path.name())
.separator("]")
.setChildCount(1)
.fieldName("input", ExplainVersion::V3)
@@ -2542,8 +2542,12 @@ static void printBSONstr(PrinterType& printer,
}
}
-std::string ExplainGenerator::printBSON(const sbe::value::TypeTags tag,
- const sbe::value::Value val) {
+std::string ExplainGenerator::explainBSONStr(const ABT& node,
+ bool displayProperties,
+ const cascades::MemoExplainInterface* memoInterface,
+ const NodeToGroupPropsMap& nodeMap) {
+ const auto [tag, val] = explainBSON(node, displayProperties, memoInterface, nodeMap);
+ sbe::value::ValueGuard vg(tag, val);
ExplainPrinterImpl<ExplainVersion::V2> printer;
printBSONstr(printer, tag, val);
return printer.str();