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 b59f53efb3
)
This commit is contained in:
parent
4d67bb6afa
commit
0f14d32792
3
src/db.c
3
src/db.c
|
@ -2193,7 +2193,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.
|
||||
|
|
|
@ -97,6 +97,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…
Reference in New Issue