提交 16fa22f1 编写于 作者: P Pieter Noordhuis

make sure that cmpobj is in decoded form when sorting by ALPHA (this solves...

make sure that cmpobj is in decoded form when sorting by ALPHA (this solves edge case from previous commit where (!sortby && alpha) == 1)
上级 6d7d1370
...@@ -6569,14 +6569,9 @@ static int sortCompare(const void *s1, const void *s2) { ...@@ -6569,14 +6569,9 @@ 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 */ /* Compare elements directly. Note that these objects already
robj *dec1, *dec2; * need to be non-encoded (see sortCommand). */
cmp = strcoll(so1->obj->ptr,so2->obj->ptr);
dec1 = getDecodedObject(so1->obj);
dec2 = getDecodedObject(so2->obj);
cmp = strcoll(dec1->ptr,dec2->ptr);
decrRefCount(dec1);
decrRefCount(dec2);
} }
} }
return server.sort_desc ? -cmp : cmp; return server.sort_desc ? -cmp : cmp;
...@@ -6720,14 +6715,13 @@ static void sortCommand(redisClient *c) { ...@@ -6720,14 +6715,13 @@ static void sortCommand(redisClient *c) {
} 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);
} else { } else if (byval->encoding == REDIS_ENCODING_INT) {
/* Don't need to decode the object if it's /* Don't need to decode the object if it's
* integer-encoded (the only encoding supported) so * integer-encoded (the only encoding supported) so
* far. We can just cast it */ * far. We can just cast it */
if (byval->encoding == REDIS_ENCODING_INT) { vector[j].u.score = (long)byval->ptr;
vector[j].u.score = (long)byval->ptr; } else {
} else redisAssert(1 != 1);
redisAssert(1 != 1);
} }
/* clean up immediately if this value came from a zipmap */ /* clean up immediately if this value came from a zipmap */
...@@ -6832,7 +6826,7 @@ static void sortCommand(redisClient *c) { ...@@ -6832,7 +6826,7 @@ static void sortCommand(redisClient *c) {
decrRefCount(sortval); decrRefCount(sortval);
listRelease(operations); listRelease(operations);
for (j = 0; j < vectorlen; j++) { for (j = 0; j < vectorlen; j++) {
if (sortby && alpha && vector[j].u.cmpobj) if (alpha && vector[j].u.cmpobj)
decrRefCount(vector[j].u.cmpobj); decrRefCount(vector[j].u.cmpobj);
} }
zfree(vector); zfree(vector);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册