@@ -107,30 +107,29 @@ namespace mongo {
107107 * @param createDefaultIndexes - if false, defers id (and other) index creation.
108108 * @return true if successful
109109 */
110- bool userCreateNS (const char *ns, BSONObj options, string& err,
111- bool logForReplication, bool createDefaultIndexes ) {
110+ Status userCreateNS ( const StringData& ns,
111+ BSONObj options,
112+ bool logForReplication,
113+ bool createDefaultIndexes ) {
112114
113115 LOG (1 ) << " create collection " << ns << ' ' << options;
114116
115- massert ( 10356 ,
116- str::stream () << " invalid ns: " << ns ,
117- NamespaceString::validCollectionComponent (ns) );
117+ if ( ! NamespaceString::validCollectionComponent (ns) )
118+ return Status ( ErrorCodes::InvalidNamespace ,
119+ str::stream () << " invalid ns: " << ns );
118120
119121 Database* db = cc ().database ();
120122
121123 Collection* collection = db->getCollection ( ns );
122124
123- if ( collection ) {
124- err = " collection already exists" ;
125- return false ;
126- }
125+ if ( collection )
126+ return Status ( ErrorCodes::NamespaceExists,
127+ " collection already exists" );
127128
128129 CollectionOptions collectionOptions;
129130 Status status = collectionOptions.parse ( options );
130- if ( !status.isOK () ) {
131- err = status.toString ();
132- return false ;
133- }
131+ if ( !status.isOK () )
132+ return status;
134133
135134 invariant ( db->createCollection ( ns, collectionOptions, true , createDefaultIndexes ) );
136135
@@ -144,7 +143,8 @@ namespace mongo {
144143 string logNs = nsToDatabase (ns) + " .$cmd" ;
145144 logOp (" c" , logNs.c_str (), options);
146145 }
147- return true ;
146+
147+ return Status::OK ();
148148 }
149149
150150 void dropAllDatabasesExceptLocal () {
0 commit comments