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
290a63dc
"vscode:/vscode.git/clone" did not exist on "3bab69e921039ad2e4f56c5842c4cf3e73a598dd"
Commit
290a63dc
authored
Mar 06, 2018
by
Guy Benoish
Browse files
Don't call sdscmp() with shared.maxstring or shared.minstring
parent
3a5bf75e
Changes
2
Show whitespace changes
Inline
Side-by-side
src/t_zset.c
View file @
290a63dc
...
@@ -519,12 +519,12 @@ int zslParseLexRangeItem(robj *item, sds *dest, int *ex) {
...
@@ -519,12 +519,12 @@ int zslParseLexRangeItem(robj *item, sds *dest, int *ex) {
switch(c[0]) {
switch(c[0]) {
case '+':
case '+':
if (c[1] != '\0') return C_ERR;
if (c[1] != '\0') return C_ERR;
*ex =
0
;
*ex =
1
;
*dest = shared.maxstring;
*dest = shared.maxstring;
return C_OK;
return C_OK;
case '-':
case '-':
if (c[1] != '\0') return C_ERR;
if (c[1] != '\0') return C_ERR;
*ex =
0
;
*ex =
1
;
*dest = shared.minstring;
*dest = shared.minstring;
return C_OK;
return C_OK;
case '(':
case '(':
...
@@ -597,9 +597,8 @@ int zslIsInLexRange(zskiplist *zsl, zlexrangespec *range) {
...
@@ -597,9 +597,8 @@ int zslIsInLexRange(zskiplist *zsl, zlexrangespec *range) {
zskiplistNode *x;
zskiplistNode *x;
/* Test for ranges that will always be empty. */
/* Test for ranges that will always be empty. */
if (sdscmplex(range->min,range->max) > 1 ||
int cmp = sdscmplex(range->min,range->max);
(sdscmp(range->min,range->max) == 0 &&
if (cmp > 0 || (cmp == 0 && (range->minex || range->maxex)))
(range->minex || range->maxex)))
return 0;
return 0;
x = zsl->tail;
x = zsl->tail;
if (x == NULL || !zslLexValueGteMin(x->ele,range))
if (x == NULL || !zslLexValueGteMin(x->ele,range))
...
@@ -872,9 +871,8 @@ int zzlIsInLexRange(unsigned char *zl, zlexrangespec *range) {
...
@@ -872,9 +871,8 @@ int zzlIsInLexRange(unsigned char *zl, zlexrangespec *range) {
unsigned char *p;
unsigned char *p;
/* Test for ranges that will always be empty. */
/* Test for ranges that will always be empty. */
if (sdscmplex(range->min,range->max) > 1 ||
int cmp = sdscmplex(range->min,range->max);
(sdscmp(range->min,range->max) == 0 &&
if (cmp > 0 || (cmp == 0 && (range->minex || range->maxex)))
(range->minex || range->maxex)))
return 0;
return 0;
p = ziplistIndex(zl,-2); /* Last element. */
p = ziplistIndex(zl,-2); /* Last element. */
...
...
tests/unit/type/zset.tcl
View file @
290a63dc
...
@@ -388,7 +388,7 @@ start_server {tags {"zset"}} {
...
@@ -388,7 +388,7 @@ start_server {tags {"zset"}} {
0 omega
}
0 omega
}
}
}
test
"ZRANGEBYLEX/ZREVRANGEBYLEX/ZCOUNT basics"
{
test
"ZRANGEBYLEX/ZREVRANGEBYLEX/Z
LEX
COUNT basics"
{
create_default_lex_zset
create_default_lex_zset
# inclusive range
# inclusive range
...
@@ -417,6 +417,22 @@ start_server {tags {"zset"}} {
...
@@ -417,6 +417,22 @@ start_server {tags {"zset"}} {
assert_equal
{}
[
r zrevrangebylex zset
(
hill
(
omega
]
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"
{
test
"ZRANGEBYSLEX with LIMIT"
{
create_default_lex_zset
create_default_lex_zset
assert_equal
{
alpha bar
}
[
r zrangebylex zset -
\[
cool LIMIT 0 2
]
assert_equal
{
alpha bar
}
[
r zrangebylex zset -
\[
cool LIMIT 0 2
]
...
...
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