summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog/index_key_validate.cpp
diff options
context:
space:
mode:
authorGregory Wlodarek <gregory.wlodarek@mongodb.com>2019-02-21 16:57:35 -0500
committerGregory Wlodarek <gregory.wlodarek@mongodb.com>2019-02-25 18:43:52 -0500
commit8464972fec625390c4856f2fc364ae4a561b511d (patch)
treec5a1111f289b95f5a61a35e31b28008e4403cfa9 /src/mongo/db/catalog/index_key_validate.cpp
parentd2850ae4977e376a30ebd542d92fd56c643fbede (diff)
downloadmongo-8464972fec625390c4856f2fc364ae4a561b511d.tar.gz
SERVER-39669 Support creating index builds with unknown options
Diffstat (limited to 'src/mongo/db/catalog/index_key_validate.cpp')
-rw-r--r--src/mongo/db/catalog/index_key_validate.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/mongo/db/catalog/index_key_validate.cpp b/src/mongo/db/catalog/index_key_validate.cpp
index 1a42eab7679..1927e0c74ae 100644
--- a/src/mongo/db/catalog/index_key_validate.cpp
+++ b/src/mongo/db/catalog/index_key_validate.cpp
@@ -27,6 +27,8 @@
* it in the license file.
*/
+#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kIndex
+
#include "mongo/platform/basic.h"
#include "mongo/db/catalog/index_key_validate.h"
@@ -49,6 +51,7 @@
#include "mongo/db/query/query_knobs_gen.h"
#include "mongo/db/service_context.h"
#include "mongo/util/fail_point_service.h"
+#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
#include "mongo/util/represent_as.h"
@@ -236,6 +239,20 @@ Status validateKeyPattern(const BSONObj& key, IndexDescriptor::IndexVersion inde
return Status::OK();
}
+BSONObj removeUnknownFields(const BSONObj& indexSpec) {
+ BSONObjBuilder builder;
+ for (const auto& indexSpecElem : indexSpec) {
+ StringData fieldName = indexSpecElem.fieldNameStringData();
+ if (allowedFieldNames.count(fieldName)) {
+ builder.append(indexSpecElem);
+ } else {
+ warning() << "Removing field '" << redact(fieldName)
+ << "' from index spec: " << redact(indexSpec);
+ }
+ }
+ return builder.obj();
+}
+
StatusWith<BSONObj> validateIndexSpec(
OperationContext* opCtx,
const BSONObj& indexSpec,