Skip to content

Commit

Permalink
SERVER-19810 rewrite pseudocommands to run on the admin database
Browse files Browse the repository at this point in the history
  • Loading branch information
amidvidy committed Aug 13, 2015
1 parent 7e3b287 commit a833bbe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions jstests/core/pseudocommand_db.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(function() {
"use strict";
var testDB = db.getSiblingDB("blah");
// test that we can run the 'inprog' pseudocommand on any database.
assert.commandWorked(testDB.$cmd.sys.inprog.findOne());

})();
6 changes: 3 additions & 3 deletions src/mongo/s/strategy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,13 +404,13 @@ bool Strategy::handleSpecialNamespaces(OperationContext* txn, Request& r, QueryM

BSONObjBuilder reply;

const auto upgradeToRealCommand = [txn, &r, &q, &reply](StringData commandName) {
const auto upgradeToRealCommand = [txn, &q, &reply](StringData commandName) {
BSONObjBuilder cmdBob;
cmdBob.append(commandName, 1);
cmdBob.appendElements(q.query); // fields are validated by Commands
auto interposedCmd = cmdBob.done();
NamespaceString nss(r.getns());
NamespaceString interposedNss(nss.db(), "$cmd");
// Rewrite upgraded pseudoCommands to run on the 'admin' database.
NamespaceString interposedNss("admin", "$cmd");
Command::runAgainstRegistered(
txn, interposedNss.ns().c_str(), interposedCmd, reply, q.queryOptions);
};
Expand Down

0 comments on commit a833bbe

Please sign in to comment.