diff options
author | Randolph Tan <randolph@10gen.com> | 2013-11-08 13:47:08 -0500 |
---|---|---|
committer | Randolph Tan <randolph@10gen.com> | 2013-11-11 17:06:14 -0500 |
commit | a2dbf35932d0cdd1fe54eb11a36f9bcde60b7333 (patch) | |
tree | e5778ab2ab385f1d9fd5171d45ee9d8e23dcfd21 /src | |
parent | b3af50b16b97b1db9711e8fa8ece33d3e001566b (diff) | |
download | mongo-a2dbf35932d0cdd1fe54eb11a36f9bcde60b7333.tar.gz |
SERVER-11627 Make the shell use write commands by default
Append --useLegacyWriteOps when running mongo shell.
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/shell/mongo.js | 9 | ||||
-rwxr-xr-x | src/mongo/shell/servers.js | 19 | ||||
-rw-r--r-- | src/mongo/shell/shell_utils.cpp | 2 | ||||
-rw-r--r-- | src/mongo/shell/utils.js | 5 |
4 files changed, 24 insertions, 11 deletions
diff --git a/src/mongo/shell/mongo.js b/src/mongo/shell/mongo.js index a6fa7e2ce4f..6a695e5b5c9 100644 --- a/src/mongo/shell/mongo.js +++ b/src/mongo/shell/mongo.js @@ -156,12 +156,5 @@ connect = function(url, user, pass) { } // {Boolean} If true, uses the write commands instead of the legacy write ops. -if (typeof(_useWriteCommandsDefault) == 'function') { - // For mongo shell - Mongo.prototype.useWriteCommands = _useWriteCommandsDefault(); -} -else { - // For other places using the v8 engine other than the mongo shell, like map reduce - Mongo.prototype.useWriteCommands = false; -} +Mongo.prototype.useWriteCommands = _useWriteCommandsDefault(); diff --git a/src/mongo/shell/servers.js b/src/mongo/shell/servers.js index a90d95d2c08..890cb2a5ad8 100755 --- a/src/mongo/shell/servers.js +++ b/src/mongo/shell/servers.js @@ -895,8 +895,9 @@ startMongoProgram = function(){ runMongoProgram = function() { var args = argumentsToArray( arguments ); + var progName = args[0]; + if ( jsTestOptions().auth ) { - var progName = args[0]; args = args.slice(1); args.unshift( progName, '-u', jsTestOptions().adminUser, @@ -905,6 +906,13 @@ runMongoProgram = function() { '--authenticationDatabase=admin' ); } + + if (progName == 'mongo' && !_useWriteCommandsDefault()) { + progName = args[0]; + args = args.slice(1); + args.unshift(progName, '--useLegacyWriteOps'); + } + return _runMongoProgram.apply( null, args ); } @@ -913,8 +921,9 @@ runMongoProgram = function() { // command line arguments to the program. Returns pid of the spawned program. startMongoProgramNoConnect = function() { var args = argumentsToArray( arguments ); + var progName = args[0]; + if ( jsTestOptions().auth ) { - var progName = args[0]; args = args.slice(1); args.unshift(progName, '-u', jsTestOptions().adminUser, @@ -922,6 +931,12 @@ startMongoProgramNoConnect = function() { '--authenticationMechanism', DB.prototype._defaultAuthenticationMechanism, '--authenticationDatabase=admin'); } + + if (progName == 'mongo' && !_useWriteCommandsDefault()) { + args = args.slice(1); + args.unshift(progName, '--useLegacyWriteOps'); + } + return _startMongoProgram.apply( null, args ); } diff --git a/src/mongo/shell/shell_utils.cpp b/src/mongo/shell/shell_utils.cpp index 1dcafa162de..69abe910d42 100644 --- a/src/mongo/shell/shell_utils.cpp +++ b/src/mongo/shell/shell_utils.cpp @@ -176,7 +176,7 @@ namespace mongo { } void initScope( Scope &scope ) { - // Need to define this method before JSFiles::mongo is executed. + // Need to define this method before JSFiles::utils is executed. scope.injectNative("_useWriteCommandsDefault", useWriteCommandsDefault); scope.externalSetup(); mongo::shell_utils::installShellUtils( scope ); diff --git a/src/mongo/shell/utils.js b/src/mongo/shell/utils.js index d910a7b258f..561a7fa5a47 100644 --- a/src/mongo/shell/utils.js +++ b/src/mongo/shell/utils.js @@ -610,6 +610,11 @@ isMasterStatePrompt = function() { return state + '> '; } +if (typeof(_useWriteCommandsDefault) == 'undefined') { + // This is for cases when the v8 engine is used other than the mongo shell, like map reduce. + _useWriteCommandsDefault = function() { return false; }; +}; + shellPrintHelper = function (x) { if (typeof (x) == "undefined") { // Make sure that we have a db var before we use it |