From 4d8700786e2f198f9ef44961196122bbb80ee640 Mon Sep 17 00:00:00 2001 From: sundb Date: Sun, 28 Nov 2021 15:02:38 +0800 Subject: [PATCH] Fix COMMAND GETKEYS on LCS (#9852) Remove lcsGetKeys to clean up the remaining STRALGO after #9733. i.e. it still used a getkeys_proc which was still looking for the KEYS or STRINGS arguments --- src/db.c | 25 ------------------------- src/server.c | 3 +-- src/server.h | 1 - tests/unit/introspection-2.tcl | 4 ++++ 4 files changed, 5 insertions(+), 28 deletions(-) diff --git a/src/db.c b/src/db.c index 8d9be361c..1dfe00f58 100644 --- a/src/db.c +++ b/src/db.c @@ -1861,31 +1861,6 @@ int georadiusGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysRes return num; } -/* LCS ... [KEYS ] ... */ -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 ] [COUNT ] [GROUP ] * STREAMS key_1 key_2 ... key_N ID_1 ID_2 ... ID_N */ int xreadGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) { diff --git a/src/server.c b/src/server.c index 2822e307a..e4ee48d65 100644 --- a/src/server.c +++ b/src/server.c @@ -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"}, diff --git a/src/server.h b/src/server.h index 78d94c7a7..a24696f6d 100644 --- a/src/server.h +++ b/src/server.h @@ -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); diff --git a/tests/unit/introspection-2.tcl b/tests/unit/introspection-2.tcl index e09b2147b..437826f76 100644 --- a/tests/unit/introspection-2.tcl +++ b/tests/unit/introspection-2.tcl @@ -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}