Browse Source

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
pull/4399/merge
Wen Hui 2 months ago committed by GitHub
parent
commit
135998ed8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/sentinel.c
  2. 1
      src/server.c
  3. 7
      src/t_list.c
  4. 4
      src/t_set.c
  5. 3
      tests/unit/type/list.tcl

2
src/sentinel.c

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

1
src/server.c

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

7
src/t_list.c

@ -679,7 +679,8 @@ void lposCommand(client *c) {
return;
if (rank == 0) {
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;
}
} 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) {
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) {
lmpopGenericCommand(c, 2, 1);
}

4
src/t_set.c

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

3
tests/unit/type/list.tcl

@ -389,12 +389,13 @@ start_server {
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 2] == 6}
assert {[r LPOS mylist c RANK 4] eq ""}
assert {[r LPOS mylist c RANK -1] == 7}
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} {

Loading…
Cancel
Save