Skip to content

Commit

Permalink
Fix COMMAND GETKEYS on LCS (redis#9852)
Browse files Browse the repository at this point in the history
Remove lcsGetKeys to clean up the remaining STRALGO after redis#9733.
i.e. it still used a getkeys_proc which was still looking for the KEYS or STRINGS arguments
  • Loading branch information
sundb authored Nov 28, 2021
1 parent 596635f commit 4d87007
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 28 deletions.
25 changes: 0 additions & 25 deletions src/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -1861,31 +1861,6 @@ int georadiusGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysRes
return num;
}

/* LCS ... [KEYS <key1> <key2>] ... */
int lcsGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) {
int i;
int *keys = getKeysPrepareResult(result, 2);
UNUSED(cmd);

/* We need to parse the options of the command in order to check for the
* "KEYS" argument before the "STRINGS" argument. */
for (i = 1; i < argc; i++) {
char *arg = argv[i]->ptr;
int moreargs = (argc-1) - i;

if (!strcasecmp(arg, "strings")) {
break;
} else if (!strcasecmp(arg, "keys") && moreargs >= 2) {
keys[0] = i+1;
keys[1] = i+2;
result->numkeys = 2;
return result->numkeys;
}
}
result->numkeys = 0;
return result->numkeys;
}

/* XREAD [BLOCK <milliseconds>] [COUNT <count>] [GROUP <groupname> <ttl>]
* STREAMS key_1 key_2 ... key_N ID_1 ID_2 ... ID_N */
int xreadGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) {
Expand Down
3 changes: 1 addition & 2 deletions src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -2023,8 +2023,7 @@ struct redisCommand redisCommandTable[] = {
"read-only @string",
{{"read",
KSPEC_BS_INDEX,.bs.index={1},
KSPEC_FK_RANGE,.fk.range={1,1,0}}},
lcsGetKeys},
KSPEC_FK_RANGE,.fk.range={1,1,0}}}},

{"quit",quitCommand,-1,
"no-auth no-script ok-stale ok-loading fast @connection"},
Expand Down
1 change: 0 additions & 1 deletion src/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -2690,7 +2690,6 @@ int sortGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *
int migrateGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result);
int georadiusGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result);
int xreadGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result);
int lcsGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result);
int lmpopGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result);
int blmpopGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result);
int zmpopGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result);
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/introspection-2.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ start_server {tags {"introspection"}} {
assert_equal {} [r command getkeys eval "return 1" 0]
}

test {COMMAND GETKEYS LCS} {
assert_equal {key1 key2} [r command getkeys lcs key1 key2]
}

test "COMMAND LIST FILTERBY ACLCAT" {
set reply [r command list filterby aclcat hyperloglog]
assert_equal [lsort $reply] {pfadd pfcount pfdebug pfmerge pfselftest}
Expand Down

0 comments on commit 4d87007

Please sign in to comment.