From 5c63d6d7e79ed26f51184e7a68c78d284468099c Mon Sep 17 00:00:00 2001 From: hwware Date: Wed, 16 Oct 2024 07:38:45 +0000 Subject: [PATCH] remove new command and relative functions --- src/commands/module-set-argument.json | 32 ----------------------- src/module.c | 35 -------------------------- tests/unit/moduleapi/moduleconfigs.tcl | 13 ---------- 3 files changed, 80 deletions(-) delete mode 100644 src/commands/module-set-argument.json diff --git a/src/commands/module-set-argument.json b/src/commands/module-set-argument.json deleted file mode 100644 index b60484e878..0000000000 --- a/src/commands/module-set-argument.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "SET-ARGUMENT": { - "summary": "Sets module arguments to new values during runtime.", - "complexity": "O(1)", - "group": "server", - "since": "8.2.0", - "arity": -3, - "container": "MODULE", - "function": "moduleCommand", - "command_flags": [ - "NO_ASYNC_LOADING", - "ADMIN", - "NOSCRIPT", - "PROTECTED" - ], - "reply_schema": { - "const": "OK" - }, - "arguments": [ - { - "name": "name", - "type": "string" - }, - { - "name": "arg", - "type": "string", - "optional": true, - "multiple": true - } - ] - } -} diff --git a/src/module.c b/src/module.c index 864c584165..f4a712d672 100644 --- a/src/module.c +++ b/src/module.c @@ -13046,22 +13046,11 @@ int VM_RdbSave(ValkeyModuleCtx *ctx, ValkeyModuleRdbStream *stream, int flags) { return VALKEYMODULE_OK; } - -void updateModuleRunTimeArgument(struct ValkeyModule *module, void **argv, int argc) { - module->loadmod->argv = argc ? zmalloc(sizeof(robj *) * argc) : NULL; - module->loadmod->argc = argc; - for (int i = 0; i < argc; i++) { - module->loadmod->argv[i] = argv[i]; - incrRefCount(module->loadmod->argv[i]); - } -} - /* MODULE command. * * MODULE LIST * MODULE LOAD [args...] * MODULE LOADEX [[CONFIG NAME VALUE] [CONFIG NAME VALUE]] [ARGS ...] - * MODULE SET-ARGUMENT [args...] * MODULE UNLOAD */ void moduleCommand(client *c) { @@ -13075,8 +13064,6 @@ void moduleCommand(client *c) { " Load a module library from , passing to it any optional arguments.", "LOADEX [[CONFIG NAME VALUE] [CONFIG NAME VALUE]] [ARGS ...]", " Load a module library from , while passing it module configurations and optional arguments.", - "SET-ARGUMENT [ ...]", - " Set module arguments to new values during runtime.", "UNLOAD ", " Unload a module.", NULL}; @@ -13123,28 +13110,6 @@ void moduleCommand(client *c) { } } else if (!strcasecmp(subcmd, "list") && c->argc == 2) { addReplyLoadedModules(c); - } else if (!strcasecmp(subcmd, "set-argument") && c->argc >= 3) { - struct ValkeyModule *module = dictFetchValue(modules, c->argv[2]->ptr); - if (module != NULL) { - for (int i = 0; i < module->loadmod->argc; i++) { - decrRefCount(module->loadmod->argv[i]); - } - zfree(module->loadmod->argv); - robj **argv = NULL; - int argc = 0; - - if (c->argc > 3) { - argc = c->argc - 3; - argv = &c->argv[3]; - } - updateModuleRunTimeArgument(module, (void **)argv, argc); - - addReply(c, shared.ok); - } else { - addReplyError(c, "Error set arguments for module: no such module with that name "); - serverLog(LL_WARNING, "Error set arguments for module %s: no such module with that name", - (sds)c->argv[2]->ptr); - } } else { addReplySubcommandSyntaxError(c); return; diff --git a/tests/unit/moduleapi/moduleconfigs.tcl b/tests/unit/moduleapi/moduleconfigs.tcl index 0ea5d94c1f..6098f91c5f 100644 --- a/tests/unit/moduleapi/moduleconfigs.tcl +++ b/tests/unit/moduleapi/moduleconfigs.tcl @@ -246,19 +246,6 @@ start_server {tags {"modules"}} { } } - test {Module Set-Argument command work} { - r module load $testmoduleparameter - - set t [r module list] - set modulename [lmap x [r module list] {dict get $x name}] - assert_not_equal [lsearch $modulename myhello] -1 - string match "" [lmap x [r module list] {dict get $x args}] - r module set-argument myhello 1 2 3 - r config rewrite - restart_server 0 true false - string match "1 2 3" [lmap x [r module list] {dict get $x args}] - } - }