mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-23 16:48:27 -05:00
Fix for a SORT bug introduced with commit 16fa22f1
, regression test added
This commit is contained in:
parent
177727542c
commit
08ee9b570f
9
redis.c
9
redis.c
@ -3058,7 +3058,7 @@ static robj *getDecodedObject(robj *o) {
|
|||||||
dec = createStringObject(buf,strlen(buf));
|
dec = createStringObject(buf,strlen(buf));
|
||||||
return dec;
|
return dec;
|
||||||
} else {
|
} else {
|
||||||
redisAssert(1 != 1);
|
redisPanic("Unknown encoding type");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6626,9 +6626,8 @@ static int sortCompare(const void *s1, const void *s2) {
|
|||||||
cmp = strcoll(so1->u.cmpobj->ptr,so2->u.cmpobj->ptr);
|
cmp = strcoll(so1->u.cmpobj->ptr,so2->u.cmpobj->ptr);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Compare elements directly. Note that these objects already
|
/* Compare elements directly. */
|
||||||
* need to be non-encoded (see sortCommand). */
|
cmp = compareStringObjects(so1->obj,so2->obj);
|
||||||
cmp = strcoll(so1->obj->ptr,so2->obj->ptr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return server.sort_desc ? -cmp : cmp;
|
return server.sort_desc ? -cmp : cmp;
|
||||||
@ -6766,7 +6765,7 @@ static void sortCommand(redisClient *c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (alpha) {
|
if (alpha) {
|
||||||
vector[j].u.cmpobj = getDecodedObject(byval);
|
if (sortby) vector[j].u.cmpobj = getDecodedObject(byval);
|
||||||
} else {
|
} else {
|
||||||
if (byval->encoding == REDIS_ENCODING_RAW) {
|
if (byval->encoding == REDIS_ENCODING_RAW) {
|
||||||
vector[j].u.score = strtod(byval->ptr,NULL);
|
vector[j].u.score = strtod(byval->ptr,NULL);
|
||||||
|
@ -935,6 +935,15 @@ proc main {} {
|
|||||||
lsort [array names myset]
|
lsort [array names myset]
|
||||||
} {a b c}
|
} {a b c}
|
||||||
|
|
||||||
|
test {SORT ALPHA against integer encoded strings} {
|
||||||
|
$r del mylist
|
||||||
|
$r lpush mylist 2
|
||||||
|
$r lpush mylist 1
|
||||||
|
$r lpush mylist 3
|
||||||
|
$r lpush mylist 10
|
||||||
|
$r sort mylist alpha
|
||||||
|
} {1 10 2 3}
|
||||||
|
|
||||||
test {Create a random list and a random set} {
|
test {Create a random list and a random set} {
|
||||||
set tosort {}
|
set tosort {}
|
||||||
array set seenrand {}
|
array set seenrand {}
|
||||||
|
Loading…
Reference in New Issue
Block a user