diff options
-rw-r--r-- | src/t_zset.c | 7 | ||||
-rw-r--r-- | tests/unit/type/zset.tcl | 9 |
2 files changed, 13 insertions, 3 deletions
diff --git a/src/t_zset.c b/src/t_zset.c index f313b8850..5660b3c7d 100644 --- a/src/t_zset.c +++ b/src/t_zset.c @@ -1192,9 +1192,10 @@ void zsetConvert(robj *zobj, int encoding) { zs->zsl = zslCreate(); eptr = ziplistIndex(zl,0); - serverAssertWithInfo(NULL,zobj,eptr != NULL); - sptr = ziplistNext(zl,eptr); - serverAssertWithInfo(NULL,zobj,sptr != NULL); + if (eptr != NULL) { + sptr = ziplistNext(zl,eptr); + serverAssertWithInfo(NULL,zobj,sptr != NULL); + } while (eptr != NULL) { score = zzlGetScore(sptr); diff --git a/tests/unit/type/zset.tcl b/tests/unit/type/zset.tcl index 94b2ab480..ec5fc2e5b 100644 --- a/tests/unit/type/zset.tcl +++ b/tests/unit/type/zset.tcl @@ -1643,6 +1643,15 @@ start_server {tags {"zset"}} { assert_match "*syntax*" $err } + test {ZRANGESTORE with zset-max-listpack-entries 0 dst key should use skiplist encoding} { + set original_max [lindex [r config get zset-max-ziplist-entries] 1] + r config set zset-max-ziplist-entries 0 + r del z1{t} z2{t} + r zadd z1{t} 1 a + assert_equal 1 [r zrangestore z2{t} z1{t} 0 -1] + r config set zset-max-ziplist-entries $original_max + } + test {ZRANGE invalid syntax} { catch {r zrange z1 0 -1 limit 1 2} err assert_match "*syntax*" $err |