allow changing notablescan at runtime via {set:} command

This commit is contained in:
Dwight
2010-10-15 17:00:34 -04:00
parent ad421070f5
commit 01a6722a25
5 changed files with 54 additions and 9 deletions

View File

@@ -25,7 +25,7 @@ namespace mongo {
/* concurrency: OK/READ */
struct CmdLine {
CmdLine() :
port(DefaultDBPort), rest(false), jsonp(false), quiet(false), notablescan(false), prealloc(true), smallfiles(false),
port(DefaultDBPort), rest(false), jsonp(false), quiet(false), noTableScan(false), prealloc(true), smallfiles(false),
quota(false), quotaFiles(8), cpu(false), oplogSize(0), defaultProfile(0), slowMS(100), pretouch(0), moveParanoia( true )
{ }
@@ -57,7 +57,7 @@ namespace mongo {
string only; // --only
bool quiet; // --quiet
bool notablescan; // --notablescan
bool noTableScan; // --notablescan
bool prealloc; // --noprealloc
bool smallfiles; // --smallfiles

View File

@@ -876,8 +876,8 @@ int main(int argc, char* argv[], char *envp[] )
if (params.count("upgrade")) {
shouldRepairDatabases = 1;
}
if (params.count("notablescan")) {
cmdLine.notablescan = true;
if (params.count("noTableScan")) {
cmdLine.noTableScan = true;
}
if (params.count("master")) {
replSettings.master = true;

View File

@@ -1625,7 +1625,6 @@ namespace mongo {
log() << "command denied: " << cmdObj.toString() << endl;
return false;
}
if ( c->adminOnly() && ! fromRepl && dbname != "admin" ) {
result.append( "errmsg" , "access denied; use admin db" );

View File

@@ -66,6 +66,54 @@ namespace mongo {
}
} cmdBuildInfo;
class CmdGet : public Command {
public:
CmdGet() : Command( "get" ) { }
virtual bool slaveOk() const { return true; }
virtual bool adminOnly() const { return true; }
virtual LockType locktype() const { return NONE; }
virtual void help( stringstream &help ) const {
help << "get administrative option(s)\nexample:\n";
help << "{ get:1, notablescan:1 }\n";
help << "supported so far:\n";
help << " notablescan\n";
}
bool run(const string& dbname, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool fromRepl ){
if( cmdObj.hasElement("notablescan") ) {
result.append("notablescan", cmdLine.noTableScan);
}
else {
errmsg = "no option found to get";
return false;
}
return true;
}
} cmdGet;
class CmdSet : public Command {
public:
CmdSet() : Command( "set" ) { }
virtual bool slaveOk() const { return true; }
virtual bool adminOnly() const { return true; }
virtual LockType locktype() const { return NONE; }
virtual void help( stringstream &help ) const {
help << "set administrative option(s)\nexample:\n";
help << "{ set:1, notablescan:true }\n";
help << "supported so far:\n";
help << " notablescan\n";
}
bool run(const string& dbname, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool fromRepl ){
if( cmdObj.hasElement("notablescan") ) {
result.append("was", cmdLine.noTableScan);
cmdLine.noTableScan = cmdObj["notablescan"].Bool();
}
else {
errmsg = "no option found to set";
return false;
}
return true;
}
} cmdSet;
/* just to check if the db has asserted */
class CmdAssertInfo : public Command {
@@ -223,6 +271,4 @@ namespace mongo {
}
} cmdForceError;
}

View File

@@ -32,7 +32,7 @@
namespace mongo {
void checkTableScanAllowed( const char * ns ){
if ( ! cmdLine.notablescan )
if ( ! cmdLine.noTableScan )
return;
if ( strstr( ns , ".system." ) ||
@@ -42,7 +42,7 @@ namespace mongo {
if ( ! nsdetails( ns ) )
return;
uassert( 10111 , (string)"table scans not allowed:" + ns , ! cmdLine.notablescan );
uassert( 10111 , (string)"table scans not allowed:" + ns , ! cmdLine.noTableScan );
}
double elementDirection( const BSONElement &e ) {