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
c7f80e4f
Commit
c7f80e4f
authored
Nov 23, 2018
by
antirez
Browse files
RESP3: Make WITHSCORES reply back with a flat array in RESP2.
parent
fe67418b
Changes
1
Show whitespace changes
Inline
Side-by-side
src/t_zset.c
View file @
c7f80e4f
...
...
@@ -2446,6 +2446,7 @@ void zrangeGenericCommand(client *c, int reverse) {
rangelen = (end-start)+1;
/* Return the result in form of a multi-bulk reply */
if (withscores && c->resp == 2) rangelen *= 2;
addReplyArrayLen(c, rangelen);
if (zobj->encoding == OBJ_ENCODING_ZIPLIST) {
...
...
@@ -2467,7 +2468,7 @@ void zrangeGenericCommand(client *c, int reverse) {
serverAssertWithInfo(c,zobj,eptr != NULL && sptr != NULL);
serverAssertWithInfo(c,zobj,ziplistGet(eptr,&vstr,&vlen,&vlong));
if
(
withscores
)
addReplyArrayLen
(
c
,
2
);
if (withscores
&& c->resp > 2
) addReplyArrayLen(c,2);
if (vstr == NULL)
addReplyBulkLongLong(c,vlong);
else
...
...
@@ -2500,7 +2501,7 @@ void zrangeGenericCommand(client *c, int reverse) {
while(rangelen--) {
serverAssertWithInfo(c,zobj,ln != NULL);
ele = ln->ele;
if
(
withscores
)
addReplyArrayLen
(
c
,
2
);
if (withscores
&& c->resp > 2
) addReplyArrayLen(c,2);
addReplyBulkCBuffer(c,ele,sdslen(ele));
if (withscores) addReplyDouble(c,ln->score);
ln = reverse ? ln->backward : ln->level[0].forward;
...
...
@@ -2628,7 +2629,7 @@ void genericZrangebyscoreCommand(client *c, int reverse) {
serverAssertWithInfo(c,zobj,ziplistGet(eptr,&vstr,&vlen,&vlong));
rangelen++;
if
(
withscores
)
addReplyArrayLen
(
c
,
2
);
if (withscores
&& c->resp > 2
) addReplyArrayLen(c,2);
if (vstr == NULL) {
addReplyBulkLongLong(c,vlong);
} else {
...
...
@@ -2685,7 +2686,7 @@ void genericZrangebyscoreCommand(client *c, int reverse) {
}
rangelen++;
if
(
withscores
)
addReplyArrayLen
(
c
,
2
);
if (withscores
&& c->resp > 2
) addReplyArrayLen(c,2);
addReplyBulkCBuffer(c,ln->ele,sdslen(ln->ele));
if (withscores) addReplyDouble(c,ln->score);
...
...
@@ -2700,6 +2701,7 @@ void genericZrangebyscoreCommand(client *c, int reverse) {
serverPanic("Unknown sorted set encoding");
}
if (withscores && c->resp == 2) rangelen *= 2;
setDeferredArrayLen(c, replylen, rangelen);
}
...
...
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