Merge pull request #3686 from dvirsky/fix_lowlevel_zrange

fixed stop condition in RM_ZsetRangeNext and RM_ZsetRangePrev
This commit is contained in:
Salvatore Sanfilippo 2016-12-16 09:20:47 +01:00 committed by GitHub
commit 5ad2a94a16

View File

@ -1858,12 +1858,12 @@ int RM_ZsetRangeNext(RedisModuleKey *key) {
} else { } else {
/* Are we still within the range? */ /* Are we still within the range? */
if (key->ztype == REDISMODULE_ZSET_RANGE_SCORE && if (key->ztype == REDISMODULE_ZSET_RANGE_SCORE &&
!zslValueLteMax(ln->score,&key->zrs)) !zslValueLteMax(next->score,&key->zrs))
{ {
key->zer = 1; key->zer = 1;
return 0; return 0;
} else if (key->ztype == REDISMODULE_ZSET_RANGE_LEX) { } else if (key->ztype == REDISMODULE_ZSET_RANGE_LEX) {
if (!zslLexValueLteMax(ln->ele,&key->zlrs)) { if (!zslLexValueLteMax(next->ele,&key->zlrs)) {
key->zer = 1; key->zer = 1;
return 0; return 0;
} }
@ -1921,7 +1921,7 @@ int RM_ZsetRangePrev(RedisModuleKey *key) {
} else { } else {
/* Are we still within the range? */ /* Are we still within the range? */
if (key->ztype == REDISMODULE_ZSET_RANGE_SCORE && if (key->ztype == REDISMODULE_ZSET_RANGE_SCORE &&
!zslValueGteMin(ln->score,&key->zrs)) !zslValueGteMin(prev->score,&key->zrs))
{ {
key->zer = 1; key->zer = 1;
return 0; return 0;