mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-13 14:39:28 +00:00
drop $db; fix group
This commit is contained in:
@@ -138,6 +138,18 @@ func (self ExampleQuery) ExplainCmd() bson.D {
|
|||||||
{"find", coll},
|
{"find", coll},
|
||||||
{"filter", filter},
|
{"filter", filter},
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
for i := range cmd {
|
||||||
|
// drop $db param as it is not supported in MongoDB 3.0
|
||||||
|
if cmd[i].Name == "$db" {
|
||||||
|
if len(cmd) - 1 == i {
|
||||||
|
cmd = cmd[:i]
|
||||||
|
} else {
|
||||||
|
cmd = append(cmd[:i], cmd[i+1:]...)
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case "update":
|
case "update":
|
||||||
s := strings.SplitN(self.Ns, ".", 2)
|
s := strings.SplitN(self.Ns, ".", 2)
|
||||||
@@ -192,8 +204,8 @@ func (self ExampleQuery) ExplainCmd() bson.D {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if v, ok := cmd[0].Value.(BsonD); ok {
|
if group, ok := cmd[0].Value.(BsonD); ok {
|
||||||
for i := range v {
|
for i := range group {
|
||||||
// for MongoDB <= 3.2
|
// for MongoDB <= 3.2
|
||||||
// "$reduce" : function () {}
|
// "$reduce" : function () {}
|
||||||
// It is then Unmarshaled as empty value, so in essence not working
|
// It is then Unmarshaled as empty value, so in essence not working
|
||||||
@@ -206,9 +218,9 @@ func (self ExampleQuery) ExplainCmd() bson.D {
|
|||||||
//
|
//
|
||||||
// The $reduce function shouldn't affect explain execution plan (e.g. what indexes are picked)
|
// The $reduce function shouldn't affect explain execution plan (e.g. what indexes are picked)
|
||||||
// so we ignore it for now until we find better way to handle this issue
|
// so we ignore it for now until we find better way to handle this issue
|
||||||
if v[i].Name == "$reduce" {
|
if group[i].Name == "$reduce" {
|
||||||
v[i].Value = ""
|
group[i].Value = "{}"
|
||||||
cmd[0].Value = v
|
cmd[0].Value = group
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user