summaryrefslogtreecommitdiff
path: root/src/mongo/db/pdfile.cpp
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2014-03-07 14:15:26 -0500
committerEliot Horowitz <eliot@10gen.com>2014-04-03 13:31:49 -0400
commitdc05a58dac1e57b60de4494a1cd352c30cf165bf (patch)
treebb775e0ac1ae7e4464891b65f23079c3e096f271 /src/mongo/db/pdfile.cpp
parenteecd33eb68036b1d0027b8ee1d297a58a395d9be (diff)
downloadmongo-dc05a58dac1e57b60de4494a1cd352c30cf165bf.tar.gz
some cleaning of userCreateNs
Diffstat (limited to 'src/mongo/db/pdfile.cpp')
-rw-r--r--src/mongo/db/pdfile.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/mongo/db/pdfile.cpp b/src/mongo/db/pdfile.cpp
index c0a5747a64e..369134b9ad2 100644
--- a/src/mongo/db/pdfile.cpp
+++ b/src/mongo/db/pdfile.cpp
@@ -107,30 +107,29 @@ namespace mongo {
* @param createDefaultIndexes - if false, defers id (and other) index creation.
* @return true if successful
*/
- bool userCreateNS(const char *ns, BSONObj options, string& err,
- bool logForReplication, bool createDefaultIndexes ) {
+ Status userCreateNS( const StringData& ns,
+ BSONObj options,
+ bool logForReplication,
+ bool createDefaultIndexes ) {
LOG(1) << "create collection " << ns << ' ' << options;
- massert(10356 ,
- str::stream() << "invalid ns: " << ns,
- NamespaceString::validCollectionComponent(ns));
+ if ( !NamespaceString::validCollectionComponent(ns) )
+ return Status( ErrorCodes::InvalidNamespace,
+ str::stream() << "invalid ns: " << ns );
Database* db = cc().database();
Collection* collection = db->getCollection( ns );
- if ( collection ) {
- err = "collection already exists";
- return false;
- }
+ if ( collection )
+ return Status( ErrorCodes::NamespaceExists,
+ "collection already exists" );
CollectionOptions collectionOptions;
Status status = collectionOptions.parse( options );
- if ( !status.isOK() ) {
- err = status.toString();
- return false;
- }
+ if ( !status.isOK() )
+ return status;
invariant( db->createCollection( ns, collectionOptions, true, createDefaultIndexes ) );
@@ -144,7 +143,8 @@ namespace mongo {
string logNs = nsToDatabase(ns) + ".$cmd";
logOp("c", logNs.c_str(), options);
}
- return true;
+
+ return Status::OK();
}
void dropAllDatabasesExceptLocal() {