summaryrefslogtreecommitdiff
path: root/src/mongo/shell/shell_utils.cpp
diff options
context:
space:
mode:
authormatt dannenberg <matt.dannenberg@10gen.com>2014-02-18 08:12:31 -0500
committermatt dannenberg <matt.dannenberg@10gen.com>2014-02-19 17:09:24 -0500
commit25bddf266b85a97d8bc17796cb0c2a0759ba639c (patch)
tree3891f8915d6de812e54205b5b8efd8e838cb23e3 /src/mongo/shell/shell_utils.cpp
parentcb382700f1807de6c67456a8284c8e4415d4b741 (diff)
downloadmongo-25bddf266b85a97d8bc17796cb0c2a0759ba639c.tar.gz
SERVER-8391 upgradeCheck() function added to shell
Diffstat (limited to 'src/mongo/shell/shell_utils.cpp')
-rw-r--r--src/mongo/shell/shell_utils.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/mongo/shell/shell_utils.cpp b/src/mongo/shell/shell_utils.cpp
index fcbaa2e535b..a4597fb99f7 100644
--- a/src/mongo/shell/shell_utils.cpp
+++ b/src/mongo/shell/shell_utils.cpp
@@ -21,6 +21,8 @@
#include "mongo/client/replica_set_monitor.h"
#include "mongo/client/dbclientinterface.h"
+#include "mongo/db/catalog/index_key_validate.h"
+#include "mongo/db/index/external_key_generator.h"
#include "mongo/scripting/engine.h"
#include "mongo/shell/shell_options.h"
#include "mongo/shell/shell_utils_extended.h"
@@ -136,6 +138,28 @@ namespace mongo {
return BSON( "" << b.done() );
}
+ BSONObj keyTooLong(const BSONObj& a, void* data) {
+ BSONObj index = a[0]["index"].Obj();
+ BSONObj doc = a[0]["doc"].Obj();
+ BSONObjSet keys;
+ getKeysForUpgradeChecking(index, doc, &keys);
+ for (BSONObjSet::const_iterator key = keys.begin(); key != keys.end(); ++key) {
+ if (key->objsize() > 1024) {
+ return BSON("" << true);
+ }
+ }
+ return BSON("" << false);
+ }
+
+ BSONObj validateIndexKey(const BSONObj& a, void* data) {
+ BSONObj key = a[0].Obj();
+ Status indexValid = validateKeyPattern(key);
+ if (!indexValid.isOK()) {
+ return BSON("" << BSON("ok" << false << "errmsg" << indexValid.codeString()));
+ }
+ return BSON("" << BSON("ok" << true));
+ }
+
BSONObj replMonitorStats(const BSONObj& a, void* data) {
uassert(17134, "replMonitorStats requires a single string argument (the ReplSet name)",
a.nFields() == 1 && a.firstElement().type() == String);
@@ -167,6 +191,8 @@ namespace mongo {
scope.injectNative( "_isWindows" , isWindows );
scope.injectNative( "interpreterVersion", interpreterVersion );
scope.injectNative( "getBuildInfo", getBuildInfo );
+ scope.injectNative( "keyTooLong", keyTooLong );
+ scope.injectNative( "validateIndexKey", validateIndexKey );
#ifndef MONGO_SAFE_SHELL
//can't launch programs