Commit 095a6e59 authored by Leibale Eidelman's avatar Leibale Eidelman Committed by Oran Agra
Browse files

fix ZRANGESTORE - should return 0 when src points to an empty key (#9089)



mistakenly it used to return an empty array rather than 0.
Co-authored-by: default avatarOran Agra <oran@redislabs.com>
(cherry picked from commit 95274f1f)
parent 56020fd8
...@@ -3663,7 +3663,12 @@ void zrangeGenericCommand(zrange_result_handler *handler, int argc_start, int st ...@@ -3663,7 +3663,12 @@ void zrangeGenericCommand(zrange_result_handler *handler, int argc_start, int st
lookupKeyWrite(c->db,key) : lookupKeyWrite(c->db,key) :
lookupKeyRead(c->db,key); lookupKeyRead(c->db,key);
if (zobj == NULL) { if (zobj == NULL) {
addReply(c,shared.emptyarray); if (store) {
handler->beginResultEmission(handler);
handler->finalizeResultEmission(handler, 0);
} else {
addReply(c, shared.emptyarray);
}
goto cleanup; goto cleanup;
} }
......
...@@ -1568,6 +1568,19 @@ start_server {tags {"zset"}} { ...@@ -1568,6 +1568,19 @@ start_server {tags {"zset"}} {
r zrange z1 5 0 BYSCORE REV LIMIT 0 2 WITHSCORES r zrange z1 5 0 BYSCORE REV LIMIT 0 2 WITHSCORES
} {d 4 c 3} } {d 4 c 3}
test {ZRANGESTORE - src key missing} {
set res [r zrangestore z2{t} missing{t} 0 -1]
assert_equal $res 0
r exists z2{t}
} {0}
test {ZRANGESTORE - src key wrong type} {
r zadd z2{t} 1 a
r set foo{t} bar
assert_error "*WRONGTYPE*" {r zrangestore z2{t} foo{t} 0 -1}
r zrange z2{t} 0 -1
} {a}
test {ZRANGESTORE - empty range} { test {ZRANGESTORE - empty range} {
set res [r zrangestore z2 z1 5 6] set res [r zrangestore z2 z1 5 6]
assert_equal $res 0 assert_equal $res 0
......
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