mirror of
https://github.com/fluencelabs/redis
synced 2025-06-24 14:31:34 +00:00
Fix ZUNIONSTORE/ZINTERSTORE to never store a NaN score.
When +inf and -inf are added, the result is NaN. We don't want NaN
scores in a sorted set, so agreed on the result of this operation being
zero. Backport of d9e28bcf
to 2.0.0.
This commit is contained in:
@ -417,6 +417,30 @@ start_server {tags {"zset"}} {
|
||||
list [r zinterstore zsetc 2 zseta zsetb aggregate max] [r zrange zsetc 0 -1 withscores]
|
||||
} {2 {b 2 c 3}}
|
||||
|
||||
foreach cmd {ZUNIONSTORE ZINTERSTORE} {
|
||||
test "$cmd with +inf/-inf scores" {
|
||||
r zadd zsetinf1 +inf key
|
||||
r zadd zsetinf2 +inf key
|
||||
r $cmd zsetinf3 2 zsetinf1 zsetinf2
|
||||
assert_equal inf [r zscore zsetinf3 key]
|
||||
|
||||
r zadd zsetinf1 -inf key
|
||||
r zadd zsetinf2 +inf key
|
||||
r $cmd zsetinf3 2 zsetinf1 zsetinf2
|
||||
assert_equal 0 [r zscore zsetinf3 key]
|
||||
|
||||
r zadd zsetinf1 +inf key
|
||||
r zadd zsetinf2 -inf key
|
||||
r $cmd zsetinf3 2 zsetinf1 zsetinf2
|
||||
assert_equal 0 [r zscore zsetinf3 key]
|
||||
|
||||
r zadd zsetinf1 -inf key
|
||||
r zadd zsetinf2 -inf key
|
||||
r $cmd zsetinf3 2 zsetinf1 zsetinf2
|
||||
assert_equal -inf [r zscore zsetinf3 key]
|
||||
}
|
||||
}
|
||||
|
||||
tags {"slow"} {
|
||||
test {ZSETs skiplist implementation backlink consistency test} {
|
||||
set diff 0
|
||||
|
Reference in New Issue
Block a user