Commit 0f14d327 authored by bodong.ybd's avatar bodong.ybd Committed by Oran Agra
Browse files

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 b59f53ef)
parent 4d67bb6a
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment