diff options
author | antirez <antirez@gmail.com> | 2013-11-05 12:16:29 +0100 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2013-11-05 17:24:22 +0100 |
commit | 54a5a7dff8832a59575c45c7bbbb4ea5a77cd000 (patch) | |
tree | 78085303d52b6221547e48945c8b8f5b5e7c15e4 | |
parent | bebbc7f9f7aeee883a48dd82e74fc2980433b168 (diff) | |
download | redis-54a5a7dff8832a59575c45c7bbbb4ea5a77cd000.tar.gz |
HSCAN/ZSCAN: skip value when matching.
This fixes issue #1360 and #1362.
-rw-r--r-- | src/db.c | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -495,11 +495,16 @@ void scanGenericCommand(redisClient *c, robj *o) { if (filter) { decrRefCount(kobj); listDelNode(keys, node); - /* Also remove the value for hashes and sorted sets. */ - if (o && (o->type == REDIS_ZSET || o->type == REDIS_HASH)) { - node = nextnode; + } + + /* If this is an hash or a sorted set, we have a flat list of + * key-value elements, so if this element was filtered, remove the + * value, or skip it if it was not filtered: we only match keys. */ + if (o && (o->type == REDIS_ZSET || o->type == REDIS_HASH)) { + node = nextnode; + nextnode = listNextNode(node); + if (filter) { kobj = listNodeValue(node); - nextnode = listNextNode(node); decrRefCount(kobj); listDelNode(keys, node); } |