diff options
author | Charlie Swanson <charlie.swanson@mongodb.com> | 2018-04-05 17:38:02 -0400 |
---|---|---|
committer | Charlie Swanson <charlie.swanson@mongodb.com> | 2018-04-05 21:28:45 -0400 |
commit | 74aa83de852e3f3740eccb065a7d43d7708e138a (patch) | |
tree | 609509abc9dfe4b68c8fa77e9984622d4f15ca0e /src | |
parent | 41f13212be110fc2360804fc04982273e43910f4 (diff) | |
download | mongo-74aa83de852e3f3740eccb065a7d43d7708e138a.tar.gz |
SERVER-33323 Fix pushBack, remove const from size_t, and fix s390x
Check if the pipeline is empty before setting the new stage to point to
the last one in Pipeline::pushBack().
Remove unnecessary const qualifier from std::size_t return types.
Work around a compiler bug on s390x by allowing a CursorResponse to be
copied.
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/pipeline/pipeline.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/query/cursor_response.h | 15 | ||||
-rw-r--r-- | src/mongo/s/query/cluster_client_cursor.h | 2 | ||||
-rw-r--r-- | src/mongo/s/query/cluster_client_cursor_impl.cpp | 2 | ||||
-rw-r--r-- | src/mongo/s/query/cluster_client_cursor_impl.h | 2 | ||||
-rw-r--r-- | src/mongo/s/query/cluster_client_cursor_mock.cpp | 2 | ||||
-rw-r--r-- | src/mongo/s/query/cluster_client_cursor_mock.h | 2 | ||||
-rw-r--r-- | src/mongo/s/query/cluster_cursor_manager.cpp | 2 | ||||
-rw-r--r-- | src/mongo/s/query/cluster_cursor_manager.h | 2 |
9 files changed, 25 insertions, 8 deletions
diff --git a/src/mongo/db/pipeline/pipeline.cpp b/src/mongo/db/pipeline/pipeline.cpp index 335ca4f5655..c784bdd624f 100644 --- a/src/mongo/db/pipeline/pipeline.cpp +++ b/src/mongo/db/pipeline/pipeline.cpp @@ -613,7 +613,9 @@ Status Pipeline::_pipelineCanRunOnMongoS() const { } void Pipeline::pushBack(boost::intrusive_ptr<DocumentSource> newStage) { - newStage->setSource(_sources.back().get()); + if (!_sources.empty()) { + newStage->setSource(_sources.back().get()); + } _sources.push_back(std::move(newStage)); } diff --git a/src/mongo/db/query/cursor_response.h b/src/mongo/db/query/cursor_response.h index b2dd828f4c2..091b64e0c73 100644 --- a/src/mongo/db/query/cursor_response.h +++ b/src/mongo/db/query/cursor_response.h @@ -132,7 +132,13 @@ void appendGetMoreResponseObject(long long cursorId, BSONObjBuilder* builder); class CursorResponse { +// In order to work around a bug in the compiler on the s390x platform, the IDL needs to invoke the +// copy constructor on that platform. +// TODO SERVER-32467 Remove this ifndef once the compiler has been fixed and the workaround has been +// removed. +#ifndef __s390x__ MONGO_DISALLOW_COPYING(CursorResponse); +#endif public: enum class ResponseType { @@ -170,6 +176,15 @@ public: CursorResponse(CursorResponse&& other) = default; CursorResponse& operator=(CursorResponse&& other) = default; +// In order to work around a bug in the compiler on the s390x platform, the IDL needs to invoke the +// copy constructor on that platform. +// TODO SERVER-32467 Remove this ifndef once the compiler has been fixed and the workaround has been +// removed. +#ifdef __s390x__ + CursorResponse(const CursorResponse& other) = default; + CursorResponse& operator=(const CursorResponse& other) = default; +#endif + // // Accessors. // diff --git a/src/mongo/s/query/cluster_client_cursor.h b/src/mongo/s/query/cluster_client_cursor.h index 9c01c013ce6..1afb5ae1b38 100644 --- a/src/mongo/s/query/cluster_client_cursor.h +++ b/src/mongo/s/query/cluster_client_cursor.h @@ -113,7 +113,7 @@ public: /** * Returns a reference to the vector of remote hosts involved in this operation. */ - virtual const std::size_t getNumRemotes() const = 0; + virtual std::size_t getNumRemotes() const = 0; /** * Returns the number of result documents returned so far by this cursor via the next() method. diff --git a/src/mongo/s/query/cluster_client_cursor_impl.cpp b/src/mongo/s/query/cluster_client_cursor_impl.cpp index 1a4be45f1be..e5348f3d86f 100644 --- a/src/mongo/s/query/cluster_client_cursor_impl.cpp +++ b/src/mongo/s/query/cluster_client_cursor_impl.cpp @@ -147,7 +147,7 @@ BSONObj ClusterClientCursorImpl::getOriginatingCommand() const { return _params.originatingCommandObj; } -const std::size_t ClusterClientCursorImpl::getNumRemotes() const { +std::size_t ClusterClientCursorImpl::getNumRemotes() const { return _root->getNumRemotes(); } diff --git a/src/mongo/s/query/cluster_client_cursor_impl.h b/src/mongo/s/query/cluster_client_cursor_impl.h index d3c9349233b..34fa7d16c61 100644 --- a/src/mongo/s/query/cluster_client_cursor_impl.h +++ b/src/mongo/s/query/cluster_client_cursor_impl.h @@ -105,7 +105,7 @@ public: BSONObj getOriginatingCommand() const final; - const std::size_t getNumRemotes() const final; + std::size_t getNumRemotes() const final; long long getNumReturnedSoFar() const final; diff --git a/src/mongo/s/query/cluster_client_cursor_mock.cpp b/src/mongo/s/query/cluster_client_cursor_mock.cpp index 6e624f36b84..b248b35f77e 100644 --- a/src/mongo/s/query/cluster_client_cursor_mock.cpp +++ b/src/mongo/s/query/cluster_client_cursor_mock.cpp @@ -68,7 +68,7 @@ BSONObj ClusterClientCursorMock::getOriginatingCommand() const { return _originatingCommand; } -const std::size_t ClusterClientCursorMock::getNumRemotes() const { +std::size_t ClusterClientCursorMock::getNumRemotes() const { MONGO_UNREACHABLE; } diff --git a/src/mongo/s/query/cluster_client_cursor_mock.h b/src/mongo/s/query/cluster_client_cursor_mock.h index 1c50403c3ae..beb49735a8d 100644 --- a/src/mongo/s/query/cluster_client_cursor_mock.h +++ b/src/mongo/s/query/cluster_client_cursor_mock.h @@ -69,7 +69,7 @@ public: BSONObj getOriginatingCommand() const final; - const std::size_t getNumRemotes() const final; + std::size_t getNumRemotes() const final; long long getNumReturnedSoFar() const final; diff --git a/src/mongo/s/query/cluster_cursor_manager.cpp b/src/mongo/s/query/cluster_cursor_manager.cpp index ca66ee04e08..44cd6333f19 100644 --- a/src/mongo/s/query/cluster_cursor_manager.cpp +++ b/src/mongo/s/query/cluster_cursor_manager.cpp @@ -147,7 +147,7 @@ BSONObj ClusterCursorManager::PinnedCursor::getOriginatingCommand() const { return _cursor->getOriginatingCommand(); } -const std::size_t ClusterCursorManager::PinnedCursor::getNumRemotes() const { +std::size_t ClusterCursorManager::PinnedCursor::getNumRemotes() const { invariant(_cursor); return _cursor->getNumRemotes(); } diff --git a/src/mongo/s/query/cluster_cursor_manager.h b/src/mongo/s/query/cluster_cursor_manager.h index cf6dc54f21e..e8ab24cfa36 100644 --- a/src/mongo/s/query/cluster_cursor_manager.h +++ b/src/mongo/s/query/cluster_cursor_manager.h @@ -198,7 +198,7 @@ public: /** * Returns a reference to the vector of remote hosts involved in this operation. */ - const std::size_t getNumRemotes() const; + std::size_t getNumRemotes() const; /** * Returns the cursor id for the underlying cursor, or zero if no cursor is owned. |