Skip to content

Don't call sdscmp() with shared.maxstring or shared.minstring - #4737

Merged
antirez merged 1 commit into
redis:unstablefrom
guybe7:zlexcount_fix
Nov 28, 2018
Merged

antirez merged 1 commit into
redis:unstablefrom
guybe7:zlexcount_fix

Conversation

@guybe7

@guybe7 guybe7 commented Mar 6, 2018

Copy link
Copy Markdown
Collaborator
127.0.0.1:6379> ZADD z 0 x
(integer) 1
127.0.0.1:6379> ZLEXCOUNT z (maxstring +
(integer) 0

ZLEXCOUNT should return 1

The problem occurs because of a call to sdscmp with shared.maxstring (which has the actual value of "maxstring") so it is basically equivalent to an empty range

Another problem was that in order to test empty ranges, sdscmplex(range->min,range->max) > 1 was used instead of sdscmplex(range->min,range->max) > 0

Finally, I changed shared.maxstring and shared.minstring to be exclusive so that the test for empty ranges will exit ASAP in case of ZLEXCOUNT z - - or ZLEXCOUNT z + +

@antirez
antirez merged commit 6a6471a into redis:unstable Nov 28, 2018
@antirez

antirez commented Nov 28, 2018

Copy link
Copy Markdown
Contributor

Thanks @guybe7, sorry for the delay.

JackieXie168 pushed a commit to JackieXie168/redis that referenced this pull request Dec 17, 2018
Don't call sdscmp() with shared.maxstring or shared.minstring
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants