diff options
author | Eliot Horowitz <eliot@10gen.com> | 2013-12-20 18:55:43 -0500 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2013-12-22 20:21:50 -0500 |
commit | 90bdeb9e6657afb9ca71a62db0996c040e0fafdd (patch) | |
tree | 2fe1846242d0fb71997cf307cdfe41fffc103387 /src/mongo/db/instance.cpp | |
parent | 68f0e4c16e9c38b8a04c697e58c6ff81f04a9c6e (diff) | |
download | mongo-90bdeb9e6657afb9ca71a62db0996c040e0fafdd.tar.gz |
SERVER-11611: move all user facing inserts to Collection::insertDocument
Diffstat (limited to 'src/mongo/db/instance.cpp')
-rw-r--r-- | src/mongo/db/instance.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/mongo/db/instance.cpp b/src/mongo/db/instance.cpp index 5c98f815efa..25778602d02 100644 --- a/src/mongo/db/instance.cpp +++ b/src/mongo/db/instance.cpp @@ -588,6 +588,7 @@ namespace mongo { void receivedUpdate(Message& m, CurOp& op) { DbMessage d(m); NamespaceString ns(d.getns()); + uassertStatusOK( userAllowedWriteNS( ns ) ); op.debug().ns = ns.ns(); int flags = d.pullInt(); BSONObj query = d.nextJsObj(); @@ -673,6 +674,7 @@ namespace mongo { void receivedDelete(Message& m, CurOp& op) { DbMessage d(m); NamespaceString ns(d.getns()); + uassertStatusOK( userAllowedWriteNS( ns ) ); op.debug().ns = ns.ns(); int flags = d.pullInt(); @@ -843,6 +845,7 @@ namespace mongo { void checkAndInsert(Client::Context& ctx, const char *ns, /*modifies*/BSONObj& js) { if ( nsToCollectionSubstring( ns ) == "system.indexes" ) { string targetNS = js["ns"].String(); + uassertStatusOK( userAllowedWriteNS( targetNS ) ); Collection* collection = ctx.db()->getCollection( targetNS ); if ( !collection ) { @@ -851,9 +854,12 @@ namespace mongo { verify( collection ); } - Status status = collection->getIndexCatalog()->createIndex( js, true ); + bool mayInterrupt = cc().curop()->parent() == NULL; + Status status = collection->getIndexCatalog()->createIndex( js, mayInterrupt ); + if ( status.code() == ErrorCodes::IndexAlreadyExists ) return; + uassertStatusOK( status ); logOp( "i", ns, js ); return; @@ -861,6 +867,8 @@ namespace mongo { StatusWith<BSONObj> fixed = fixDocumentForInsert( js ); uassertStatusOK( fixed.getStatus() ); + if ( !fixed.getValue().isEmpty() ) + js = fixed.getValue(); Collection* collection = ctx.db()->getCollection( ns ); if ( !collection ) { @@ -897,6 +905,8 @@ namespace mongo { const char *ns = d.getns(); op.debug().ns = ns; + uassertStatusOK( userAllowedWriteNS( ns ) ); + if( !d.moreJSObjs() ) { // strange. should we complain? return; |