diff options
Diffstat (limited to 'src/mongo/db/catalog/rename_collection.cpp')
-rw-r--r-- | src/mongo/db/catalog/rename_collection.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/mongo/db/catalog/rename_collection.cpp b/src/mongo/db/catalog/rename_collection.cpp index 7b60c794129..452ed2a6e01 100644 --- a/src/mongo/db/catalog/rename_collection.cpp +++ b/src/mongo/db/catalog/rename_collection.cpp @@ -745,10 +745,9 @@ void doLocalRenameIfOptionsAndIndexesHaveNotChanged(OperationContext* opCtx, validateAndRunRenameCollection(opCtx, sourceNs, targetNs, options); } -void validateAndRunRenameCollection(OperationContext* opCtx, - const NamespaceString& source, - const NamespaceString& target, - const RenameCollectionOptions& options) { +void validateNamespacesForRenameCollection(OperationContext* opCtx, + const NamespaceString& source, + const NamespaceString& target) { uassert(ErrorCodes::InvalidNamespace, str::stream() << "Invalid source namespace: " << source.ns(), source.isValid()); @@ -786,6 +785,23 @@ void validateAndRunRenameCollection(OperationContext* opCtx, "allowed"); } + uassert(ErrorCodes::NamespaceNotFound, + str::stream() << "renameCollection cannot accept a source collection that is in a " + "drop-pending state: " + << source, + !source.isDropPendingNamespace()); + + uassert(ErrorCodes::IllegalOperation, + "renaming system.views collection or renaming to system.views is not allowed", + !source.isSystemDotViews() && !target.isSystemDotViews()); +} + +void validateAndRunRenameCollection(OperationContext* opCtx, + const NamespaceString& source, + const NamespaceString& target, + const RenameCollectionOptions& options) { + validateNamespacesForRenameCollection(opCtx, source, target); + OperationShardingState::ScopedAllowImplicitCollectionCreate_UNSAFE unsafeCreateCollection( opCtx); uassertStatusOK(renameCollection(opCtx, source, target, options)); |