Fix sort_ro get-keys function return wrong key number (#12522)
Before: ``` 127.0.0.1:6379> command getkeys sort_ro key (empty array) 127.0.0.1:6379> ``` After: ``` 127.0.0.1:6379> command getkeys sort_ro key 1) "key" 127.0.0.1:6379> ``` (cherry picked from commit b59f53efb31b36d0a307809f5d33bf66d66a4447)
This commit is contained in:
parent
68305c5b99
commit
9e505e6cd8
3
src/db.c
3
src/db.c
@ -2294,7 +2294,8 @@ int sortROGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult
|
||||
keys = getKeysPrepareResult(result, 1);
|
||||
keys[0].pos = 1; /* <sort-key> is always present. */
|
||||
keys[0].flags = CMD_KEY_RO | CMD_KEY_ACCESS;
|
||||
return 1;
|
||||
result->numkeys = 1;
|
||||
return result->numkeys;
|
||||
}
|
||||
|
||||
/* Helper function to extract keys from the SORT command.
|
||||
|
@ -109,6 +109,10 @@ start_server {
|
||||
test "SORT extracts STORE correctly" {
|
||||
r command getkeys sort abc store def
|
||||
} {abc def}
|
||||
|
||||
test "SORT_RO get keys" {
|
||||
r command getkeys sort_ro abc
|
||||
} {abc}
|
||||
|
||||
test "SORT extracts multiple STORE correctly" {
|
||||
r command getkeys sort abc store invalid store stillbad store def
|
||||
|
Loading…
x
Reference in New Issue
Block a user