summaryrefslogtreecommitdiff
path: root/src/mongo/db/exec/fetch.cpp
diff options
context:
space:
mode:
authorDavid Storch <david.storch@10gen.com>2018-10-30 10:43:57 -0400
committerDavid Storch <david.storch@10gen.com>2018-10-31 17:26:35 -0400
commit6caa6abbc0f5d4681599361edba2ef1f3a775c50 (patch)
treedb969bf9c6749f6631696662a188b30a60824215 /src/mongo/db/exec/fetch.cpp
parentd6c618fc94ebdfdba5d270e396a084290a54d360 (diff)
downloadmongo-6caa6abbc0f5d4681599361edba2ef1f3a775c50.tar.gz
SERVER-37445 Make FETCH stage check collection validity on restoreState().
Diffstat (limited to 'src/mongo/db/exec/fetch.cpp')
-rw-r--r--src/mongo/db/exec/fetch.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/mongo/db/exec/fetch.cpp b/src/mongo/db/exec/fetch.cpp
index 2fc29bc8972..90654b11d92 100644
--- a/src/mongo/db/exec/fetch.cpp
+++ b/src/mongo/db/exec/fetch.cpp
@@ -55,8 +55,7 @@ FetchStage::FetchStage(OperationContext* opCtx,
PlanStage* child,
const MatchExpression* filter,
const Collection* collection)
- : PlanStage(kStageType, opCtx),
- _collection(collection),
+ : RequiresCollectionStage(kStageType, opCtx, collection),
_ws(ws),
_filter(filter),
_idRetrying(WorkingSet::INVALID_ID) {
@@ -103,7 +102,7 @@ PlanStage::StageState FetchStage::doWork(WorkingSetID* out) {
try {
if (!_cursor)
- _cursor = _collection->getCursor(getOpCtx());
+ _cursor = collection()->getCursor(getOpCtx());
if (!WorkingSetCommon::fetch(getOpCtx(), _ws, id, _cursor)) {
_ws->free(id);
@@ -133,14 +132,17 @@ PlanStage::StageState FetchStage::doWork(WorkingSetID* out) {
return status;
}
-void FetchStage::doSaveState() {
- if (_cursor)
+void FetchStage::saveState(RequiresCollTag) {
+ if (_cursor) {
_cursor->saveUnpositioned();
+ }
}
-void FetchStage::doRestoreState() {
- if (_cursor)
- _cursor->restore();
+void FetchStage::restoreState(RequiresCollTag) {
+ if (_cursor) {
+ const bool couldRestore = _cursor->restore();
+ uassert(50982, "could not restore cursor for FETCH stage", couldRestore);
+ }
}
void FetchStage::doDetachFromOperationContext() {