mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 09:00:51 +00:00
Geo: fix edge case return values for uniformity.
There were two cases outlined in issue #3512 and PR #3551 where the Geo API returned unexpected results: empty strings where NULL replies were expected, or a single null reply where an array was expected. This violates the Redis principle that Redis replies for existing keys or elements should be indistinguishable. This is technically an API breakage so will be merged only into 4.0 and specified in the changelog in the list of breaking compatibilities, even if it is not very likely that actual code will be affected, hopefully, since with the past behavior basically there was to acconut for *both* the possibilities, and the new behavior is always one of the two, but in a consistent way.
This commit is contained in:
parent
8444b46d20
commit
913070a9e8
@ -738,16 +738,15 @@ void geoposCommand(client *c) {
|
|||||||
int j;
|
int j;
|
||||||
|
|
||||||
/* Look up the requested zset */
|
/* Look up the requested zset */
|
||||||
robj *zobj = NULL;
|
robj *zobj = lookupKeyRead(c->db, c->argv[1]);
|
||||||
if ((zobj = lookupKeyReadOrReply(c, c->argv[1], shared.emptymultibulk))
|
if (zobj && checkType(c, zobj, OBJ_ZSET)) return;
|
||||||
== NULL || checkType(c, zobj, OBJ_ZSET)) return;
|
|
||||||
|
|
||||||
/* Report elements one after the other, using a null bulk reply for
|
/* Report elements one after the other, using a null bulk reply for
|
||||||
* missing elements. */
|
* missing elements. */
|
||||||
addReplyMultiBulkLen(c,c->argc-2);
|
addReplyMultiBulkLen(c,c->argc-2);
|
||||||
for (j = 2; j < c->argc; j++) {
|
for (j = 2; j < c->argc; j++) {
|
||||||
double score;
|
double score;
|
||||||
if (zsetScore(zobj, c->argv[j]->ptr, &score) == C_ERR) {
|
if (!zobj || zsetScore(zobj, c->argv[j]->ptr, &score) == C_ERR) {
|
||||||
addReply(c,shared.nullmultibulk);
|
addReply(c,shared.nullmultibulk);
|
||||||
} else {
|
} else {
|
||||||
/* Decode... */
|
/* Decode... */
|
||||||
@ -782,7 +781,7 @@ void geodistCommand(client *c) {
|
|||||||
|
|
||||||
/* Look up the requested zset */
|
/* Look up the requested zset */
|
||||||
robj *zobj = NULL;
|
robj *zobj = NULL;
|
||||||
if ((zobj = lookupKeyReadOrReply(c, c->argv[1], shared.emptybulk))
|
if ((zobj = lookupKeyReadOrReply(c, c->argv[1], shared.nullbulk))
|
||||||
== NULL || checkType(c, zobj, OBJ_ZSET)) return;
|
== NULL || checkType(c, zobj, OBJ_ZSET)) return;
|
||||||
|
|
||||||
/* Get the scores. We need both otherwise NULL is returned. */
|
/* Get the scores. We need both otherwise NULL is returned. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user