summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/document_source_change_stream_transform.cpp
diff options
context:
space:
mode:
authorCharlie Swanson <charlie.swanson@mongodb.com>2018-10-26 13:21:10 -0400
committerCharlie Swanson <charlie.swanson@mongodb.com>2018-11-07 09:50:09 -0500
commit505114314a5f4309f2857573db442604cb0e2b26 (patch)
tree925a6c921b8405d59ae976bad9439887a6e4a8c9 /src/mongo/db/pipeline/document_source_change_stream_transform.cpp
parentf3349bac21f200cf2f9854eb51b359d3cbee3617 (diff)
downloadmongo-505114314a5f4309f2857573db442604cb0e2b26.tar.gz
SERVER-37779 Step up enforcement that $changeStream must be first
Adds an additional check which enforces a $changeStream stage must be the first stage in the pipeline which is robust to the case where a $changeStream is only ever sent to a mongos.
Diffstat (limited to 'src/mongo/db/pipeline/document_source_change_stream_transform.cpp')
-rw-r--r--src/mongo/db/pipeline/document_source_change_stream_transform.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/mongo/db/pipeline/document_source_change_stream_transform.cpp b/src/mongo/db/pipeline/document_source_change_stream_transform.cpp
index 150b310b30c..405a3bd303c 100644
--- a/src/mongo/db/pipeline/document_source_change_stream_transform.cpp
+++ b/src/mongo/db/pipeline/document_source_change_stream_transform.cpp
@@ -434,6 +434,11 @@ DocumentSource::GetModPathsReturn DocumentSourceChangeStreamTransform::getModifi
DocumentSource::GetNextResult DocumentSourceChangeStreamTransform::getNext() {
pExpCtx->checkForInterrupt();
+ uassert(50988,
+ "Illegal attempt to execute an internal change stream stage on mongos. A $changeStream "
+ "stage must be the first stage in a pipeline",
+ !pExpCtx->inMongos);
+
// If we're unwinding an 'applyOps' from a transaction, check if there are any documents we have
// stored that can be returned.
if (_txnContext) {