mirror of
https://github.com/fluencelabs/redis
synced 2025-03-31 14:51:04 +00:00
Cluster: don't allow GET option in cluster mode.
The commit also refactors a bit the error handling during SORT option parsing.
This commit is contained in:
parent
8caecc9ab4
commit
03344196f3
23
src/sort.c
23
src/sort.c
@ -194,6 +194,7 @@ void sortCommand(redisClient *c) {
|
|||||||
int j, dontsort = 0, vectorlen;
|
int j, dontsort = 0, vectorlen;
|
||||||
int getop = 0; /* GET operation counter */
|
int getop = 0; /* GET operation counter */
|
||||||
int int_convertion_error = 0;
|
int int_convertion_error = 0;
|
||||||
|
int syntax_error = 0;
|
||||||
robj *sortval, *sortby = NULL, *storekey = NULL;
|
robj *sortval, *sortby = NULL, *storekey = NULL;
|
||||||
redisSortObject *vector; /* Resulting vector to sort */
|
redisSortObject *vector; /* Resulting vector to sort */
|
||||||
|
|
||||||
@ -236,9 +237,8 @@ void sortCommand(redisClient *c) {
|
|||||||
(getLongFromObjectOrReply(c, c->argv[j+2], &limit_count, NULL)
|
(getLongFromObjectOrReply(c, c->argv[j+2], &limit_count, NULL)
|
||||||
!= REDIS_OK))
|
!= REDIS_OK))
|
||||||
{
|
{
|
||||||
decrRefCount(sortval);
|
syntax_error++;
|
||||||
listRelease(operations);
|
break;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
j+=2;
|
j+=2;
|
||||||
} else if (!strcasecmp(c->argv[j]->ptr,"store") && leftargs >= 1) {
|
} else if (!strcasecmp(c->argv[j]->ptr,"store") && leftargs >= 1) {
|
||||||
@ -251,19 +251,30 @@ void sortCommand(redisClient *c) {
|
|||||||
if (strchr(c->argv[j+1]->ptr,'*') == NULL) dontsort = 1;
|
if (strchr(c->argv[j+1]->ptr,'*') == NULL) dontsort = 1;
|
||||||
j++;
|
j++;
|
||||||
} else if (!strcasecmp(c->argv[j]->ptr,"get") && leftargs >= 1) {
|
} else if (!strcasecmp(c->argv[j]->ptr,"get") && leftargs >= 1) {
|
||||||
|
if (server.cluster_enabled) {
|
||||||
|
addReplyError(c,"GET option of SORT denied in Cluster mode.");
|
||||||
|
syntax_error++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
listAddNodeTail(operations,createSortOperation(
|
listAddNodeTail(operations,createSortOperation(
|
||||||
REDIS_SORT_GET,c->argv[j+1]));
|
REDIS_SORT_GET,c->argv[j+1]));
|
||||||
getop++;
|
getop++;
|
||||||
j++;
|
j++;
|
||||||
} else {
|
} else {
|
||||||
decrRefCount(sortval);
|
|
||||||
listRelease(operations);
|
|
||||||
addReply(c,shared.syntaxerr);
|
addReply(c,shared.syntaxerr);
|
||||||
return;
|
syntax_error++;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Handle syntax errors set during options parsing. */
|
||||||
|
if (syntax_error) {
|
||||||
|
decrRefCount(sortval);
|
||||||
|
listRelease(operations);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* For the STORE option, or when SORT is called from a Lua script,
|
/* For the STORE option, or when SORT is called from a Lua script,
|
||||||
* we want to force a specific ordering even when no explicit ordering
|
* we want to force a specific ordering even when no explicit ordering
|
||||||
* was asked (SORT BY nosort). This guarantees that replication / AOF
|
* was asked (SORT BY nosort). This guarantees that replication / AOF
|
||||||
|
Loading…
x
Reference in New Issue
Block a user