我结束了修补蒙戈源代码(mongo/cleint/dbclient.cpp
):
bool DBClientWithCommands::ensureIndex(const string &ns , BSONObj keys , bool unique, const string & name , bool cache, bool background, int version, bool sparse) {
BSONObjBuilder toSave;
toSave.append("ns" , ns);
toSave.append("key" , keys);
string cacheKey(ns);
cacheKey += "--";
if (name != "") {
toSave.append("name" , name);
cacheKey += name;
}
else {
string nn = genIndexName(keys);
toSave.append("name" , nn);
cacheKey += nn;
}
if(version >= 0)
toSave.append("v", version);
if (unique)
toSave.appendBool("unique", unique);
if (sparse)
toSave.appendBool("sparse", true);
if(background)
toSave.appendBool("background", true);
if (_seenIndexes.count(cacheKey))
return 0;
if (cache)
_seenIndexes.insert(cacheKey);
insert(Namespace(ns.c_str()).getSisterNS("system.indexes" ).c_str() , toSave.obj());
return 1;
}
的问题应该是在版本2.3.2 resolved
这似乎有些施工过程中使用的变量都是私人的,在课堂之外不要修改。我最终修补了C++驱动程序代码。 – Xyand