summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Erf <erf@mongodb.com>2014-11-18 13:44:23 -0500
committerKyle Erf <erf@mongodb.com>2014-11-18 13:44:23 -0500
commitb47cd532e4cfb6ca21da21b94416285cc7a4ff61 (patch)
tree508cbc7b8f44173e5b4bf319b563928bbed27c21
parent96eda10bb667305f7fc97937e19e6706655215e6 (diff)
downloadmongo-b47cd532e4cfb6ca21da21b94416285cc7a4ff61.tar.gz
TOOLS-186 client-side index namespace check in mongorestore
Former-commit-id: 93fc3e00ea87719c25d67ba266027da27a633d63
-rw-r--r--mongorestore/metadata.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/mongorestore/metadata.go b/mongorestore/metadata.go
index e5c7f0f5f54..f038f146042 100644
--- a/mongorestore/metadata.go
+++ b/mongorestore/metadata.go
@@ -129,6 +129,14 @@ func (restore *MongoRestore) CreateIndexes(intent *intents.Intent, indexes []Ind
// update the namespace of the index before inserting
index.Options["ns"] = intent.Key()
+ // check for length violations before building the command
+ fullIndexName := fmt.Sprintf("%v.$%v", index.Options["ns"], index.Options["name"])
+ if len(fullIndexName) > 127 {
+ return fmt.Errorf(
+ "cannot restore index with namespace '%v': "+
+ "namespace is too long (max size is 127 characters)", fullIndexName)
+ }
+
// remove the index version, forcing an update,
// unless we specifically want to keep it
if !restore.OutputOptions.KeepIndexVersion {