SERVER-21706 error when mapReduce outputs to config or admin db

(cherry picked from commit 3e1a3872c9)
This commit is contained in:
Misha Tyulenev 2015-12-14 19:19:03 -05:00
parent 5770fdcdf7
commit 126cecc636
2 changed files with 24 additions and 0 deletions

View File

@ -10,4 +10,20 @@ assert.commandFailed(testDB.runCommand({ mapReduce: 'user',
reduce: reduceFunc,
out: { inline: 1, sharded: true }}));
testDB.bar.insert({i: 1});
assert.commandFailed(testDB.runCommand({ mapReduce: 'bar',
map: function() {emit(this.i, this.i*3);},
reduce: function(key, values) {return Array.sum(values)},
out: { replace: "foo", db: "admin" }}));
assert.commandFailed(testDB.runCommand({ mapReduce: 'bar',
map: function() {emit(this.i, this.i*3);},
reduce: function(key, values) {return Array.sum(values)},
out: { replace: "foo", db: "config" }}));
assert.commandWorked(testDB.runCommand({ mapReduce: 'bar',
map: function() {emit(this.i, this.i*3);},
reduce: function(key, values) {return Array.sum(values)},
out: { replace: "foo", db: "test" }}));
st.stop();

View File

@ -1566,6 +1566,14 @@ public:
int,
string& errmsg,
BSONObjBuilder& result) {
if (!grid.shardRegistry()) {
return appendCommandStatus(
result,
Status(ErrorCodes::CommandNotSupported,
str::stream() << "Can not execute mapReduce with output database "
<< dbname));
}
boost::optional<DisableDocumentValidation> maybeDisableValidation;
if (shouldBypassDocumentValidationForCommand(cmdObj))
maybeDisableValidation.emplace(txn);