summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/document_source_out.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/pipeline/document_source_out.h')
-rw-r--r--src/mongo/db/pipeline/document_source_out.h22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/mongo/db/pipeline/document_source_out.h b/src/mongo/db/pipeline/document_source_out.h
index f8ee8829038..4ae2c9af5e8 100644
--- a/src/mongo/db/pipeline/document_source_out.h
+++ b/src/mongo/db/pipeline/document_source_out.h
@@ -38,8 +38,26 @@ namespace mongo {
*/
class DocumentSourceOut : public DocumentSource, public NeedsMergerDocumentSource {
public:
- static std::unique_ptr<LiteParsedDocumentSourceForeignCollections> liteParse(
- const AggregationRequest& request, const BSONElement& spec);
+ /**
+ * A "lite parsed" $out stage is similar to other stages involving foreign collections except in
+ * some cases the foreign collection is allowed to be sharded.
+ */
+ class LiteParsed final : public LiteParsedDocumentSourceForeignCollections {
+ public:
+ static std::unique_ptr<LiteParsed> parse(const AggregationRequest& request,
+ const BSONElement& spec);
+
+ LiteParsed(NamespaceString outNss, PrivilegeVector privileges, bool allowShardedOutNss)
+ : LiteParsedDocumentSourceForeignCollections(outNss, privileges),
+ _allowShardedOutNss(allowShardedOutNss) {}
+
+ bool allowShardedForeignCollection(NamespaceString nss) const final {
+ return _allowShardedOutNss ? true : (_foreignNssSet.find(nss) == _foreignNssSet.end());
+ }
+
+ private:
+ bool _allowShardedOutNss;
+ };
DocumentSourceOut(const NamespaceString& outputNs,
const boost::intrusive_ptr<ExpressionContext>& expCtx,