Details
-
Bug
-
Resolution: Unresolved
-
Major - P3
-
None
-
5.0.12
-
None
-
Query Execution
-
ALL
-
- run the golang program
- run getIndexes will get the error
Description
Environment
mongo-go-driver version: "v1.10.6"
mongod version: "50.0.12"
Problem
When creating indexes through runCommand interface, user can pass a index specification with duplicated fields, which can cause errors when listIndexes etc.
package main import ( |
"go.mongodb.org/mongo-driver/bson" |
"go.mongodb.org/mongo-driver/mongo" |
"go.mongodb.org/mongo-driver/mongo/options" |
"context" |
)func main() {
|
ctx := context.TODO()
|
var err error
|
clientOpt := options.Client().ApplyURI("mongodb://user:password@127.0.0.1:7089") |
client, err := mongo.Connect(ctx, clientOpt)
|
if err != nil { |
panic(err)
|
}
|
database := client.Database("ycsb") |
res := database.RunCommand(context.Background(), bson.D{
|
{"createIndexes", "test"}, |
{"indexes", bson.A{ |
bson.D{
|
{"v", 2}, |
{"key", bson.D{{"mars", 1},{"moon",1},{"sun",1},{"lastLoginDate",-1}}}, |
{"key", bson.D{{"a",1}}}, |
{"name","mars_1_moon_1_sun_1_lastLoginDate_-1"}, |
{"background",true}, |
{"background",true}}}}}) if res.Err() != nil { |
panic(res.Err())
|
}
|
}
|
|
Running the progrem will cause getIndexes() throw errors

createIndexes command should check duplidated fields in validate process
Attachments
Issue Links
- is duplicated by
-
SERVER-80718 CreateIndexes command accepts index spec with duplicated fields which cause error
-
- Closed
-
- links to