forked from mirror/redis
Fix Command parsing
This commit is contained in:
parent
12d46bf32e
commit
2e8ce55021
28
command.go
28
command.go
|
@ -2072,7 +2072,13 @@ func (cmd *CommandsInfoCmd) readReply(rd *proto.Reader) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func commandInfoParser(rd *proto.Reader, n int64) (interface{}, error) {
|
func commandInfoParser(rd *proto.Reader, n int64) (interface{}, error) {
|
||||||
if n != 7 {
|
const numArgRedis5 = 6
|
||||||
|
const numArgRedis6 = 7
|
||||||
|
|
||||||
|
switch n {
|
||||||
|
case numArgRedis5, numArgRedis6:
|
||||||
|
// continue
|
||||||
|
default:
|
||||||
return nil, fmt.Errorf("redis: got %d elements in COMMAND reply, wanted 7", n)
|
return nil, fmt.Errorf("redis: got %d elements in COMMAND reply, wanted 7", n)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2126,9 +2132,20 @@ func commandInfoParser(rd *proto.Reader, n int64) (interface{}, error) {
|
||||||
}
|
}
|
||||||
cmd.StepCount = int8(stepCount)
|
cmd.StepCount = int8(stepCount)
|
||||||
|
|
||||||
|
for _, flag := range cmd.Flags {
|
||||||
|
if flag == "readonly" {
|
||||||
|
cmd.ReadOnly = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if n == numArgRedis5 {
|
||||||
|
return &cmd, nil
|
||||||
|
}
|
||||||
|
|
||||||
_, err = rd.ReadReply(func(rd *proto.Reader, n int64) (interface{}, error) {
|
_, err = rd.ReadReply(func(rd *proto.Reader, n int64) (interface{}, error) {
|
||||||
cmd.ACLFlags = make([]string, n)
|
cmd.ACLFlags = make([]string, n)
|
||||||
for i := 0; i < len(cmd.Flags); i++ {
|
for i := 0; i < len(cmd.ACLFlags); i++ {
|
||||||
switch s, err := rd.ReadString(); {
|
switch s, err := rd.ReadString(); {
|
||||||
case err == Nil:
|
case err == Nil:
|
||||||
cmd.ACLFlags[i] = ""
|
cmd.ACLFlags[i] = ""
|
||||||
|
@ -2144,13 +2161,6 @@ func commandInfoParser(rd *proto.Reader, n int64) (interface{}, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, flag := range cmd.Flags {
|
|
||||||
if flag == "readonly" {
|
|
||||||
cmd.ReadOnly = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return &cmd, nil
|
return &cmd, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue