diff options
Diffstat (limited to 'src/mongo/db/pipeline/document_source_coll_stats.cpp')
-rw-r--r-- | src/mongo/db/pipeline/document_source_coll_stats.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/mongo/db/pipeline/document_source_coll_stats.cpp b/src/mongo/db/pipeline/document_source_coll_stats.cpp index df6063dad52..a02a6018231 100644 --- a/src/mongo/db/pipeline/document_source_coll_stats.cpp +++ b/src/mongo/db/pipeline/document_source_coll_stats.cpp @@ -85,6 +85,17 @@ intrusive_ptr<DocumentSource> DocumentSourceCollStats::createFromBson( << " of type " << typeName(elem.type()), elem.type() == BSONType::Object); + } else if ("queryExecStats" == fieldName) { + uassert(31141, + str::stream() << "queryExecStats argument must be an empty object, but got " + << elem + << " of type " + << typeName(elem.type()), + elem.type() == BSONType::Object); + uassert(31170, + str::stream() << "queryExecStats argument must be an empty object, but got " + << elem, + elem.embeddedObject().isEmpty()); } else { uasserted(40168, str::stream() << "unrecognized option to $collStats: " << fieldName); } @@ -149,6 +160,16 @@ DocumentSource::GetNextResult DocumentSourceCollStats::getNext() { } } + if (_collStatsSpec.hasField("queryExecStats")) { + Status status = pExpCtx->mongoProcessInterface->appendQueryExecStats( + pExpCtx->opCtx, pExpCtx->ns, &builder); + if (!status.isOK()) { + uasserted(31142, + str::stream() << "Unable to retrieve queryExecStats in $collStats stage: " + << status.reason()); + } + } + return {Document(builder.obj())}; } |