summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandolph Tan <randolph@10gen.com>2012-04-13 10:46:45 -0400
committerAndy Schwerin <schwerin@10gen.com>2012-04-18 18:15:04 -0400
commitb39c6a7e185aa19a8029b27a24f27936634b9c17 (patch)
tree0739642c856b0f9a1f47d2df821d461a7e237847
parent05b07daf5be2a90b70aec40328d8c3b20e60d68b (diff)
downloadmongo-b39c6a7e185aa19a8029b27a24f27936634b9c17.tar.gz
SERVER-5384 segfault attempting mapreduce with --noscripting
-rw-r--r--db/commands/mr.cpp1
-rw-r--r--jstests/mr_noscripting.js24
2 files changed, 25 insertions, 0 deletions
diff --git a/db/commands/mr.cpp b/db/commands/mr.cpp
index b79e62b3381..9b10f99861e 100644
--- a/db/commands/mr.cpp
+++ b/db/commands/mr.cpp
@@ -940,6 +940,7 @@ namespace mongo {
log(1) << "mr ns: " << config.ns << endl;
+ uassert( 16149 , "cannot run map reduce without the js engine", globalScriptEngine );
bool shouldHaveData = false;
long long num = 0;
diff --git a/jstests/mr_noscripting.js b/jstests/mr_noscripting.js
new file mode 100644
index 00000000000..cd7f53ae28d
--- /dev/null
+++ b/jstests/mr_noscripting.js
@@ -0,0 +1,24 @@
+var conn = MongoRunner.runMongod({ noscripting: '' });
+var testDB = conn.getDB( 'foo' );
+var coll = testDB.bar;
+
+coll.insert({ x: 1 });
+
+var map = function() {
+ emit( this.x, 1 );
+};
+
+var reduce = function( key, values ) {
+ return 1;
+};
+
+var mrResult = testDB.runCommand({ mapReduce: 'bar', map: map, reduce: reduce,
+ out: { inline: 1 }});
+
+assert.eq( 0, mrResult.ok, 'mr result: ' + tojson( mrResult ));
+
+// Confirm that mongod did not crash
+var cmdResult = testDB.adminCommand({ serverStatus: 1 });
+assert( cmdResult.ok, 'serverStatus failed, result: ' +
+ tojson( cmdResult ));
+