Update comments on command args, and a misleading error reply (#10645)

Updated the comments for:
info command
lmpopCommand and blmpopCommand
sinterGenericCommand 

Fix the missing "key" words in the srandmemberCommand function
For LPOS command, when rank is 0, prompt user that rank could be
positive number or negative number, and add a test for it
This commit is contained in:
Wen Hui 2022-05-13 10:55:49 -04:00 committed by GitHub
parent 586a16ad79
commit 135998ed8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 7 deletions

View File

@ -4127,7 +4127,7 @@ numargserr:
void addInfoSectionsToDict(dict *section_dict, char **sections); void addInfoSectionsToDict(dict *section_dict, char **sections);
/* SENTINEL INFO [section] */ /* INFO [<section> [<section> ...]] */
void sentinelInfoCommand(client *c) { void sentinelInfoCommand(client *c) {
char *sentinel_sections[] = {"server", "clients", "cpu", "stats", "sentinel", NULL}; char *sentinel_sections[] = {"server", "clients", "cpu", "stats", "sentinel", NULL};
int sec_all = 0, sec_everything = 0; int sec_all = 0, sec_everything = 0;

View File

@ -5917,6 +5917,7 @@ sds genRedisInfoString(dict *section_dict, int all_sections, int everything) {
return info; return info;
} }
/* INFO [<section> [<section> ...]] */
void infoCommand(client *c) { void infoCommand(client *c) {
if (server.sentinel_mode) { if (server.sentinel_mode) {
sentinelInfoCommand(c); sentinelInfoCommand(c);

View File

@ -679,7 +679,8 @@ void lposCommand(client *c) {
return; return;
if (rank == 0) { if (rank == 0) {
addReplyError(c,"RANK can't be zero: use 1 to start from " addReplyError(c,"RANK can't be zero: use 1 to start from "
"the first match, 2 from the second, ..."); "the first match, 2 from the second ... "
"or use negative to start from the end of the list");
return; return;
} }
} else if (!strcasecmp(opt,"COUNT") && moreargs) { } else if (!strcasecmp(opt,"COUNT") && moreargs) {
@ -1197,12 +1198,12 @@ void lmpopGenericCommand(client *c, int numkeys_idx, int is_block) {
} }
} }
/* LMPOP numkeys [<key> ...] LEFT|RIGHT [COUNT count] */ /* LMPOP numkeys <key> [<key> ...] (LEFT|RIGHT) [COUNT count] */
void lmpopCommand(client *c) { void lmpopCommand(client *c) {
lmpopGenericCommand(c, 1, 0); lmpopGenericCommand(c, 1, 0);
} }
/* BLMPOP timeout numkeys [<key> ...] LEFT|RIGHT [COUNT count] */ /* BLMPOP timeout numkeys <key> [<key> ...] (LEFT|RIGHT) [COUNT count] */
void blmpopCommand(client *c) { void blmpopCommand(client *c) {
lmpopGenericCommand(c, 2, 1); lmpopGenericCommand(c, 2, 1);
} }

View File

@ -805,7 +805,7 @@ void srandmemberWithCountCommand(client *c) {
} }
} }
/* SRANDMEMBER [<count>] */ /* SRANDMEMBER <key> [<count>] */
void srandmemberCommand(client *c) { void srandmemberCommand(client *c) {
robj *set; robj *set;
sds ele; sds ele;
@ -850,7 +850,7 @@ int qsortCompareSetsByRevCardinality(const void *s1, const void *s2) {
return 0; return 0;
} }
/* SINTER / SINTERSTORE / SINTERCARD /* SINTER / SMEMBERS / SINTERSTORE / SINTERCARD
* *
* 'cardinality_only' work for SINTERCARD, only return the cardinality * 'cardinality_only' work for SINTERCARD, only return the cardinality
* with minimum processing and memory overheads. * with minimum processing and memory overheads.

View File

@ -389,12 +389,13 @@ start_server {
assert {[r LPOS mylist c] == 2} assert {[r LPOS mylist c] == 2}
} }
test {LPOS RANK (positive and negative rank) option} { test {LPOS RANK (positive, negative and zero rank) option} {
assert {[r LPOS mylist c RANK 1] == 2} assert {[r LPOS mylist c RANK 1] == 2}
assert {[r LPOS mylist c RANK 2] == 6} assert {[r LPOS mylist c RANK 2] == 6}
assert {[r LPOS mylist c RANK 4] eq ""} assert {[r LPOS mylist c RANK 4] eq ""}
assert {[r LPOS mylist c RANK -1] == 7} assert {[r LPOS mylist c RANK -1] == 7}
assert {[r LPOS mylist c RANK -2] == 6} assert {[r LPOS mylist c RANK -2] == 6}
assert_error "*RANK can't be zero: use 1 to start from the first match, 2 from the second ... or use negative to start*" {r LPOS mylist c RANK 0}
} }
test {LPOS COUNT option} { test {LPOS COUNT option} {