diff options
Diffstat (limited to 'src/mongo/db/pipeline/document_source_internal_all_collection_stats.cpp')
-rw-r--r-- | src/mongo/db/pipeline/document_source_internal_all_collection_stats.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/mongo/db/pipeline/document_source_internal_all_collection_stats.cpp b/src/mongo/db/pipeline/document_source_internal_all_collection_stats.cpp index 73782cd88c4..bbc07b66bc4 100644 --- a/src/mongo/db/pipeline/document_source_internal_all_collection_stats.cpp +++ b/src/mongo/db/pipeline/document_source_internal_all_collection_stats.cpp @@ -62,12 +62,14 @@ DocumentSource::GetNextResult DocumentSourceInternalAllCollectionStats::doGetNex continue; } - try { - return {Document{DocumentSourceCollStats::makeStatsForNs( - pExpCtx, nss, _internalAllCollectionStatsSpec.getStats().get(), _projectFilter)}}; - } catch (const ExceptionFor<ErrorCodes::CommandNotSupportedOnView>&) { - // We don't want to retrieve data for views, only for collections. - continue; + if (const auto& stats = _internalAllCollectionStatsSpec.getStats()) { + try { + return {Document{DocumentSourceCollStats::makeStatsForNs( + pExpCtx, nss, stats.get(), _projectFilter)}}; + } catch (const ExceptionFor<ErrorCodes::CommandNotSupportedOnView>&) { + // We don't want to retrieve data for views, only for collections. + continue; + } } } |