Feat:Add "copy" command

Add "copy" command,also fixes the out of range error of select when the number is negative.

Move execCopy to "keys.go" ,
Add test in "keys_test.go",
Add "copy.go" and "copy_test.go" file.
This commit is contained in:
Eriri
2022-06-23 15:20:07 +08:00
committed by finley
parent 7a9cbb7c11
commit f327000d3a
9 changed files with 395 additions and 3 deletions

View File

@@ -42,7 +42,7 @@ func execSelect(c redis.Connection, args [][]byte) redis.Reply {
if err != nil {
return protocol.MakeErrReply("ERR invalid DB index")
}
if dbIndex >= config.Properties.Databases {
if dbIndex >= config.Properties.Databases || dbIndex < 0 {
return protocol.MakeErrReply("ERR DB index is out of range")
}
c.SelectDB(dbIndex)