This prevents testing upgrade/downgrade between MongoDB 3.4 and MongoDB 3.2 without first dropping all collections and indexes that were created in MongoDB 3.4. If KeyString v1 is supposed to be separate from BSON 1.1 (i.e. the decimal data type), then having an additional server parameter to configure kCurrentIndexVersion seems desirable.
One idea for patching this issue
Unable to find source-code formatter for language: diff. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp index c0b04a4..7a2ef04 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp @@ -82,14 +82,10 @@ static const int TempKeyMaxSize = 1024; // this goes away with SERVER-3372 static const WiredTigerItem emptyItem(NULL, 0); +static const int kKeyStringV0Version = 6; static const int kKeyStringV1Version = 7; -static const int kMinimumIndexVersion = 6; -static const int kCurrentIndexVersion = kKeyStringV1Version; // New indexes use this by default. +static const int kMinimumIndexVersion = kKeyStringV0Version; static const int kMaximumIndexVersion = kKeyStringV1Version; -static_assert(kCurrentIndexVersion >= kMinimumIndexVersion, - "kCurrentIndexVersion >= kMinimumIndexVersion"); -static_assert(kCurrentIndexVersion <= kMaximumIndexVersion, - "kCurrentIndexVersion <= kMaximumIndexVersion"); bool hasFieldNames(const BSONObj& obj) { BSONForEach(e, obj) { @@ -198,7 +194,7 @@ StatusWith<std::string> WiredTigerIndex::generateCreateString(const std::string& // Index metadata ss << ",app_metadata=(" - << "formatVersion=" << (enableBSON1_1 ? kKeyStringV1Version : kCurrentIndexVersion) << ',' + << "formatVersion=" << (enableBSON1_1 ? kKeyStringV1Version : kKeyStringV0Version) << ',' << "infoObj=" << desc.infoObj().jsonString() << "),"; LOG(3) << "index create string: " << ss.ss.str();