Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
7c8cf5ac
Commit
7c8cf5ac
authored
Mar 06, 2018
by
Guy Benoish
Committed by
antirez
Dec 11, 2018
Browse files
Don't call sdscmp() with shared.maxstring or shared.minstring
parent
39e9eda3
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/t_zset.c
View file @
7c8cf5ac
...
...
@@ -574,12 +574,12 @@ int zslParseLexRangeItem(robj *item, sds *dest, int *ex) {
switch(c[0]) {
case '+':
if (c[1] != '\0') return C_ERR;
*ex =
0
;
*ex =
1
;
*dest = shared.maxstring;
return C_OK;
case '-':
if (c[1] != '\0') return C_ERR;
*ex =
0
;
*ex =
1
;
*dest = shared.minstring;
return C_OK;
case '(':
...
...
@@ -652,9 +652,8 @@ int zslIsInLexRange(zskiplist *zsl, zlexrangespec *range) {
zskiplistNode *x;
/* Test for ranges that will always be empty. */
if (sdscmplex(range->min,range->max) > 1 ||
(sdscmp(range->min,range->max) == 0 &&
(range->minex || range->maxex)))
int cmp = sdscmplex(range->min,range->max);
if (cmp > 0 || (cmp == 0 && (range->minex || range->maxex)))
return 0;
x = zsl->tail;
if (x == NULL || !zslLexValueGteMin(x->ele,range))
...
...
@@ -927,9 +926,8 @@ int zzlIsInLexRange(unsigned char *zl, zlexrangespec *range) {
unsigned char *p;
/* Test for ranges that will always be empty. */
if (sdscmplex(range->min,range->max) > 1 ||
(sdscmp(range->min,range->max) == 0 &&
(range->minex || range->maxex)))
int cmp = sdscmplex(range->min,range->max);
if (cmp > 0 || (cmp == 0 && (range->minex || range->maxex)))
return 0;
p = ziplistIndex(zl,-2); /* Last element. */
...
...
tests/unit/type/zset.tcl
View file @
7c8cf5ac
...
...
@@ -388,7 +388,7 @@ start_server {tags {"zset"}} {
0 omega
}
}
test
"ZRANGEBYLEX/ZREVRANGEBYLEX/ZCOUNT basics"
{
test
"ZRANGEBYLEX/ZREVRANGEBYLEX/Z
LEX
COUNT basics"
{
create_default_lex_zset
# inclusive range
...
...
@@ -416,6 +416,22 @@ start_server {tags {"zset"}} {
assert_equal
{}
[
r zrevrangebylex zset
\[
elez
\[
elex
]
assert_equal
{}
[
r zrevrangebylex zset
(
hill
(
omega
]
}
test
"ZLEXCOUNT advanced"
{
create_default_lex_zset
assert_equal 9
[
r zlexcount zset - +
]
assert_equal 0
[
r zlexcount zset + -
]
assert_equal 0
[
r zlexcount zset +
\[
c
]
assert_equal 0
[
r zlexcount zset
\[
c -
]
assert_equal 8
[
r zlexcount zset
\[
bar +
]
assert_equal 5
[
r zlexcount zset
\[
bar
\[
foo
]
assert_equal 4
[
r zlexcount zset
\[
bar
(
foo
]
assert_equal 4
[
r zlexcount zset
(
bar
\[
foo
]
assert_equal 3
[
r zlexcount zset
(
bar
(
foo
]
assert_equal 5
[
r zlexcount zset -
(
foo
]
assert_equal 1
[
r zlexcount zset
(
maxstring +
]
}
test
"ZRANGEBYSLEX with LIMIT"
{
create_default_lex_zset
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment