Unverified Commit 056a43e1 authored by Yossi Gottlieb's avatar Yossi Gottlieb Committed by GitHub
Browse files

Modules: fix RM_GetCommandKeys API. (#7901)

This cleans up and simplifies the API by passing the command name as the
first argument. Previously the command name was specified explicitly,
but was still included in the argv.
parent adc3183c
...@@ -8020,13 +8020,13 @@ int RM_ModuleTypeReplaceValue(RedisModuleKey *key, moduleType *mt, void *new_val ...@@ -8020,13 +8020,13 @@ int RM_ModuleTypeReplaceValue(RedisModuleKey *key, moduleType *mt, void *new_val
* get automatically freed even when auto-memory is used. The caller * get automatically freed even when auto-memory is used. The caller
* must explicitly call RM_Free() to free it. * must explicitly call RM_Free() to free it.
*/ */
int *RM_GetCommandKeys(RedisModuleCtx *ctx, const char *cmdname, RedisModuleString **argv, int argc, int *num_keys) { int *RM_GetCommandKeys(RedisModuleCtx *ctx, RedisModuleString **argv, int argc, int *num_keys) {
UNUSED(ctx); UNUSED(ctx);
struct redisCommand *cmd; struct redisCommand *cmd;
int *res = NULL; int *res = NULL;
/* Find command */ /* Find command */
if ((cmd = lookupCommandByCString(cmdname)) == NULL) { if ((cmd = lookupCommand(argv[0]->ptr)) == NULL) {
errno = ENOENT; errno = ENOENT;
return NULL; return NULL;
} }
......
...@@ -762,7 +762,7 @@ REDISMODULE_API int (*RedisModule_AuthenticateClientWithACLUser)(RedisModuleCtx ...@@ -762,7 +762,7 @@ REDISMODULE_API int (*RedisModule_AuthenticateClientWithACLUser)(RedisModuleCtx
REDISMODULE_API int (*RedisModule_AuthenticateClientWithUser)(RedisModuleCtx *ctx, RedisModuleUser *user, RedisModuleUserChangedFunc callback, void *privdata, uint64_t *client_id) REDISMODULE_ATTR; REDISMODULE_API int (*RedisModule_AuthenticateClientWithUser)(RedisModuleCtx *ctx, RedisModuleUser *user, RedisModuleUserChangedFunc callback, void *privdata, uint64_t *client_id) REDISMODULE_ATTR;
REDISMODULE_API int (*RedisModule_DeauthenticateAndCloseClient)(RedisModuleCtx *ctx, uint64_t client_id) REDISMODULE_ATTR; REDISMODULE_API int (*RedisModule_DeauthenticateAndCloseClient)(RedisModuleCtx *ctx, uint64_t client_id) REDISMODULE_ATTR;
REDISMODULE_API RedisModuleString * (*RedisModule_GetClientCertificate)(RedisModuleCtx *ctx, uint64_t id) REDISMODULE_ATTR; REDISMODULE_API RedisModuleString * (*RedisModule_GetClientCertificate)(RedisModuleCtx *ctx, uint64_t id) REDISMODULE_ATTR;
REDISMODULE_API int *(*RedisModule_GetCommandKeys)(RedisModuleCtx *ctx, const char *cmdname, RedisModuleString **argv, int argc, int *num_keys) REDISMODULE_ATTR; REDISMODULE_API int *(*RedisModule_GetCommandKeys)(RedisModuleCtx *ctx, RedisModuleString **argv, int argc, int *num_keys) REDISMODULE_ATTR;
#endif #endif
#define RedisModule_IsAOFClient(id) ((id) == CLIENT_ID_AOF) #define RedisModule_IsAOFClient(id) ((id) == CLIENT_ID_AOF)
......
...@@ -69,11 +69,8 @@ int getkeys_introspect(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) ...@@ -69,11 +69,8 @@ int getkeys_introspect(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
return REDISMODULE_OK; return REDISMODULE_OK;
} }
size_t cmd_len;
const char *cmd = RedisModule_StringPtrLen(argv[1], &cmd_len);
int num_keys; int num_keys;
int *keyidx = RedisModule_GetCommandKeys(ctx, cmd, &argv[1], argc - 1, &num_keys); int *keyidx = RedisModule_GetCommandKeys(ctx, &argv[1], argc - 1, &num_keys);
if (!keyidx) { if (!keyidx) {
if (!errno) if (!errno)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment