mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
nsToClient -> nsToDatabase
This commit is contained in:
parent
578f1973ea
commit
d531f77f67
@ -237,7 +237,7 @@ namespace mongo {
|
||||
if ( size ) b.append("size", size);
|
||||
if ( capped ) b.append("capped", true);
|
||||
if ( max ) b.append("max", max);
|
||||
string db = nsToClient(ns.c_str());
|
||||
string db = nsToDatabase(ns.c_str());
|
||||
return runCommand(db.c_str(), b.done(), *info);
|
||||
}
|
||||
|
||||
@ -590,7 +590,7 @@ namespace mongo {
|
||||
|
||||
void DBClientWithCommands::dropIndex( const string& ns , const string& indexName ){
|
||||
BSONObj info;
|
||||
if ( ! runCommand( nsToClient( ns.c_str() ) ,
|
||||
if ( ! runCommand( nsToDatabase( ns.c_str() ) ,
|
||||
BSON( "deleteIndexes" << NamespaceString( ns ).coll << "index" << indexName ) ,
|
||||
info ) ){
|
||||
log() << "dropIndex failed: " << info << endl;
|
||||
@ -601,7 +601,7 @@ namespace mongo {
|
||||
|
||||
void DBClientWithCommands::dropIndexes( const string& ns ){
|
||||
BSONObj info;
|
||||
uassert( 10008 , "dropIndexes failed" , runCommand( nsToClient( ns.c_str() ) ,
|
||||
uassert( 10008 , "dropIndexes failed" , runCommand( nsToDatabase( ns.c_str() ) ,
|
||||
BSON( "deleteIndexes" << NamespaceString( ns ).coll << "index" << "*") ,
|
||||
info ) );
|
||||
resetIndexCache();
|
||||
|
@ -281,7 +281,7 @@ namespace mongo {
|
||||
|
||||
bool Cloner::startCloneCollection( const char *fromhost, const char *ns, const BSONObj &query, string &errmsg, bool logForRepl, bool copyIndexes, int logSizeMb, long long &cursorId ) {
|
||||
char db[256];
|
||||
nsToClient( ns, db );
|
||||
nsToDatabase( ns, db );
|
||||
|
||||
NamespaceDetails *nsd = nsdetails( ns );
|
||||
if ( nsd ){
|
||||
@ -365,7 +365,7 @@ namespace mongo {
|
||||
|
||||
bool Cloner::finishCloneCollection( const char *fromhost, const char *ns, const BSONObj &query, long long cursorId, string &errmsg ) {
|
||||
char db[256];
|
||||
nsToClient( ns, db );
|
||||
nsToDatabase( ns, db );
|
||||
|
||||
auto_ptr< DBClientCursor > cur;
|
||||
{
|
||||
@ -653,9 +653,9 @@ namespace mongo {
|
||||
|
||||
{
|
||||
char from[256];
|
||||
nsToClient( source.c_str(), from );
|
||||
nsToDatabase( source.c_str(), from );
|
||||
char to[256];
|
||||
nsToClient( target.c_str(), to );
|
||||
nsToDatabase( target.c_str(), to );
|
||||
if ( strcmp( from, to ) == 0 ) {
|
||||
renameNamespace( source.c_str(), target.c_str() );
|
||||
return true;
|
||||
@ -686,9 +686,9 @@ namespace mongo {
|
||||
}
|
||||
|
||||
char cl[256];
|
||||
nsToClient( source.c_str(), cl );
|
||||
nsToDatabase( source.c_str(), cl );
|
||||
string sourceIndexes = string( cl ) + ".system.indexes";
|
||||
nsToClient( target.c_str(), cl );
|
||||
nsToDatabase( target.c_str(), cl );
|
||||
string targetIndexes = string( cl ) + ".system.indexes";
|
||||
{
|
||||
c = bridge.query( sourceIndexes, QUERY( "ns" << source ) );
|
||||
|
4
db/db.h
4
db/db.h
@ -50,7 +50,7 @@ namespace mongo {
|
||||
if ( path == dbpath )
|
||||
return ns;
|
||||
char cl[256];
|
||||
nsToClient(ns, cl);
|
||||
nsToDatabase(ns, cl);
|
||||
return string( cl ) + ":" + path;
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ namespace mongo {
|
||||
assertInWriteLock();
|
||||
|
||||
char cl[256];
|
||||
nsToClient(ns, cl);
|
||||
nsToDatabase(ns, cl);
|
||||
bool justCreated;
|
||||
Database *newdb = new Database(cl, justCreated, path);
|
||||
databases[key] = newdb;
|
||||
|
@ -775,7 +775,7 @@ namespace mongo {
|
||||
bool run(const char *dbname, BSONObj& jsobj, string& errmsg, BSONObjBuilder& result, bool fromRepl ){
|
||||
static DBDirectClient db;
|
||||
|
||||
string ns = nsToClient( dbname );
|
||||
string ns = nsToDatabase( dbname );
|
||||
ns += ".";
|
||||
{
|
||||
string root = jsobj.getStringField( "root" );
|
||||
@ -992,7 +992,7 @@ namespace mongo {
|
||||
}
|
||||
|
||||
char realDbName[256];
|
||||
nsToClient( dbname, realDbName );
|
||||
nsToDatabase( dbname, realDbName );
|
||||
|
||||
string fromNs = string( realDbName ) + "." + from;
|
||||
string toNs = string( realDbName ) + "." + to;
|
||||
@ -1054,7 +1054,7 @@ namespace mongo {
|
||||
}
|
||||
|
||||
char realDbName[256];
|
||||
nsToClient( dbname, realDbName );
|
||||
nsToDatabase( dbname, realDbName );
|
||||
|
||||
DBDirectClient client;
|
||||
client.dropCollection( string( realDbName ) + "." + from + ".$temp_convertToCapped" );
|
||||
@ -1322,7 +1322,7 @@ namespace mongo {
|
||||
virtual bool run(const char *dbname, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool) {
|
||||
static DBDirectClient db;
|
||||
|
||||
string ns = nsToClient(dbname) + '.' + cmdObj.firstElement().valuestr();
|
||||
string ns = nsToDatabase(dbname) + '.' + cmdObj.firstElement().valuestr();
|
||||
|
||||
Query q (cmdObj.getObjectField("query")); // defaults to {}
|
||||
BSONElement sort = cmdObj["sort"];
|
||||
|
@ -322,7 +322,7 @@ namespace mongo {
|
||||
else {
|
||||
const char *ns = m.data->_data + 4;
|
||||
char cl[256];
|
||||
nsToClient(ns, cl);
|
||||
nsToDatabase(ns, cl);
|
||||
currentOp.setNS(ns);
|
||||
AuthenticationInfo *ai = currentClient.get()->ai;
|
||||
if( !ai->isAuthorized(cl) ) {
|
||||
|
@ -656,7 +656,7 @@ namespace mongo {
|
||||
b.append("options", *options);
|
||||
BSONObj j = b.done();
|
||||
char database[256];
|
||||
nsToClient(ns, database);
|
||||
nsToDatabase(ns, database);
|
||||
string s = database;
|
||||
s += ".system.namespaces";
|
||||
theDataFileMgr.insert(s.c_str(), j.objdata(), j.objsize(), true);
|
||||
@ -690,7 +690,7 @@ namespace mongo {
|
||||
|
||||
BSONObj oldSpec;
|
||||
char database[MaxClientLen];
|
||||
nsToClient(from, database);
|
||||
nsToDatabase(from, database);
|
||||
string s = database;
|
||||
s += ".system.namespaces";
|
||||
assert( Helpers::findOne( s.c_str(), BSON( "name" << from ), oldSpec ) );
|
||||
|
@ -36,7 +36,7 @@ namespace mongo {
|
||||
const int MaxClientLen = 256; // max str len for the db name, including null char
|
||||
|
||||
// "database.a.b.c" -> "database"
|
||||
inline void nsToClient(const char *ns, char *database) {
|
||||
inline void nsToDatabase(const char *ns, char *database) {
|
||||
const char *p = ns;
|
||||
char *q = database;
|
||||
while ( *p != '.' ) {
|
||||
@ -46,13 +46,13 @@ namespace mongo {
|
||||
}
|
||||
*q = 0;
|
||||
if (q-database>=MaxClientLen) {
|
||||
log() << "nsToClient: ns too long. terminating, buf overrun condition" << endl;
|
||||
log() << "nsToDatabase: ns too long. terminating, buf overrun condition" << endl;
|
||||
dbexit( EXIT_POSSIBLE_CORRUPTION );
|
||||
}
|
||||
}
|
||||
inline string nsToClient(const char *ns) {
|
||||
inline string nsToDatabase(const char *ns) {
|
||||
char buf[MaxClientLen];
|
||||
nsToClient(ns, buf);
|
||||
nsToDatabase(ns, buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
@ -175,7 +175,7 @@ namespace mongo {
|
||||
const char *coll = strchr( ns, '.' ) + 1;
|
||||
massert( 10356 , "invalid ns", coll && *coll );
|
||||
char cl[ 256 ];
|
||||
nsToClient( ns, cl );
|
||||
nsToDatabase( ns, cl );
|
||||
bool ok = _userCreateNS(ns, j, err);
|
||||
if ( logForReplication && ok ) {
|
||||
if ( j.getField( "create" ).eoo() ) {
|
||||
@ -1375,7 +1375,7 @@ namespace mongo {
|
||||
const char *name = io.getStringField("name"); // name of the index
|
||||
tabletoidxns = io.getStringField("ns"); // table it indexes
|
||||
uassert( 10096 , "invalid ns to index" , tabletoidxns.size() && tabletoidxns.find( '.' ) != string::npos );
|
||||
if ( cc().database()->name != nsToClient(tabletoidxns.c_str()) ) {
|
||||
if ( cc().database()->name != nsToDatabase(tabletoidxns.c_str()) ) {
|
||||
uassert( 10097 , "bad table to index name on add index attempt", false);
|
||||
return DiskLoc();
|
||||
}
|
||||
@ -1621,7 +1621,7 @@ namespace mongo {
|
||||
void dropDatabase(const char *ns) {
|
||||
// ns is of the form "<dbname>.$cmd"
|
||||
char cl[256];
|
||||
nsToClient(ns, cl);
|
||||
nsToDatabase(ns, cl);
|
||||
log(1) << "dropDatabase " << cl << endl;
|
||||
assert( cc().database()->name == cl );
|
||||
|
||||
@ -1729,7 +1729,7 @@ namespace mongo {
|
||||
|
||||
// ns is of the form "<dbname>.$cmd"
|
||||
char dbName[256];
|
||||
nsToClient(ns, dbName);
|
||||
nsToDatabase(ns, dbName);
|
||||
problem() << "repairDatabase " << dbName << endl;
|
||||
assert( cc().database()->name == dbName );
|
||||
|
||||
|
@ -407,7 +407,7 @@ namespace mongo {
|
||||
assert( database );
|
||||
DEV {
|
||||
char buf[256];
|
||||
nsToClient(ns, buf);
|
||||
nsToDatabase(ns, buf);
|
||||
if ( database->name != buf ) {
|
||||
out() << "ERROR: attempt to write to wrong database database\n";
|
||||
out() << " ns:" << ns << '\n';
|
||||
|
@ -836,7 +836,7 @@ namespace mongo {
|
||||
|
||||
char clientName[MaxClientLen];
|
||||
const char *ns = op.getStringField("ns");
|
||||
nsToClient(ns, clientName);
|
||||
nsToDatabase(ns, clientName);
|
||||
|
||||
if ( *ns == '.' ) {
|
||||
problem() << "skipping bad op in oplog: " << op.toString() << endl;
|
||||
@ -1388,7 +1388,7 @@ namespace mongo {
|
||||
if ( master ) {
|
||||
_logOp(opstr, ns, "local.oplog.$main", obj, patt, b, OpTime::now());
|
||||
char cl[ 256 ];
|
||||
nsToClient( ns, cl );
|
||||
nsToDatabase( ns, cl );
|
||||
}
|
||||
NamespaceDetailsTransient &t = NamespaceDetailsTransient::get_w( ns );
|
||||
if ( t.cllEnabled() ) {
|
||||
|
@ -142,7 +142,7 @@ namespace mongo {
|
||||
}
|
||||
inline bool isMasterNs( const char *ns ) {
|
||||
char cl[ 256 ];
|
||||
nsToClient( ns, cl );
|
||||
nsToDatabase( ns, cl );
|
||||
return isMaster( cl );
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user