diff options
author | Aaron Staple <aaron@10gen.com> | 2009-07-29 15:53:14 -0400 |
---|---|---|
committer | Aaron Staple <aaron@10gen.com> | 2009-07-29 15:53:14 -0400 |
commit | 5dcdc3a59caf6f503637c13902ed7f002d25328c (patch) | |
tree | eb1dd55818df5c6c01e9bec2c661628b8b49e618 /db/cloner.cpp | |
parent | d5b720a5e6673d0071c2f9edef1300e17c7ff07f (diff) | |
download | mongo-5dcdc3a59caf6f503637c13902ed7f002d25328c.tar.gz |
fast collection renaming within a database
Diffstat (limited to 'db/cloner.cpp')
-rw-r--r-- | db/cloner.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/db/cloner.cpp b/db/cloner.cpp index 0a83669255f..65b865ad617 100644 --- a/db/cloner.cpp +++ b/db/cloner.cpp @@ -572,6 +572,18 @@ namespace mongo { size += i.ext()->length; setClient( target.c_str() ); + uassert( "target namespace exists", !nsdetails( target.c_str() ) ); + + { + char from[256]; + nsToClient( source.c_str(), from ); + char to[256]; + nsToClient( target.c_str(), to ); + if ( strcmp( from, to ) == 0 ) { + renameNamespace( source.c_str(), target.c_str() ); + return true; + } + } BSONObjBuilder spec; if ( capped ) { |