summaryrefslogtreecommitdiff
path: root/src/mongo/dbtests/querytests.cpp
diff options
context:
space:
mode:
authorMax Hirschhorn <max.hirschhorn@mongodb.com>2016-09-14 20:49:17 -0400
committerMax Hirschhorn <max.hirschhorn@mongodb.com>2016-09-14 20:49:17 -0400
commit8302d0735b34a16cac000e5e345722487536e5bc (patch)
treec9ef60fe493eda60feacddfd67c0ec298939c4ef /src/mongo/dbtests/querytests.cpp
parent46acb1b94944bc7aa68ff6a8b3cd2d340b272c6f (diff)
downloadmongo-8302d0735b34a16cac000e5e345722487536e5bc.tar.gz
SERVER-24033 Write full index spec in oplog entry for index creation.
This ensures that the index version (aka the "v" field) is always present in the oplog entry when creating indexes on a 3.4 primary. We can therefore assume that if the "v" field isn't present in the corresponding oplog entry, then a v=1 index should be built. Changes MultiBlockIndex::init() to return the index specifications that were actually created. The "repairDatabase", "compact", "copydb", and "cloneCollection" commands no longer automatically upgrade the index version to the current default version. Instead, the only command that does so is the "reIndex" command.
Diffstat (limited to 'src/mongo/dbtests/querytests.cpp')
-rw-r--r--src/mongo/dbtests/querytests.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/mongo/dbtests/querytests.cpp b/src/mongo/dbtests/querytests.cpp
index 888d9bd4454..de55f54f45d 100644
--- a/src/mongo/dbtests/querytests.cpp
+++ b/src/mongo/dbtests/querytests.cpp
@@ -40,6 +40,7 @@
#include "mongo/db/dbdirectclient.h"
#include "mongo/db/dbhelpers.h"
#include "mongo/db/global_timestamp.h"
+#include "mongo/db/index/index_descriptor.h"
#include "mongo/db/json.h"
#include "mongo/db/lasterror.h"
#include "mongo/db/query/find.h"
@@ -56,6 +57,10 @@ using std::endl;
using std::string;
using std::vector;
+namespace {
+const auto kIndexVersion = IndexDescriptor::IndexVersion::kV2;
+} // namespace
+
class Base {
public:
Base() : _scopedXact(&_txn, MODE_X), _lk(_txn.lockState()), _context(&_txn, ns()) {
@@ -89,7 +94,8 @@ protected:
}
void addIndex(const BSONObj& key) {
- Helpers::ensureIndex(&_txn, _collection, key, false, key.firstElementFieldName());
+ Helpers::ensureIndex(
+ &_txn, _collection, key, kIndexVersion, false, key.firstElementFieldName());
}
void insert(const char* s) {