summaryrefslogtreecommitdiff
path: root/src/eval.c
diff options
context:
space:
mode:
authormeir@redislabs.com <meir@redislabs.com>2021-10-07 14:41:26 +0300
committermeir <meir@redis.com>2021-12-02 19:35:52 +0200
commitcbd463175f8b52d594fd4e6b953fa58a5db053c3 (patch)
tree2b2e4080b6b4d399eaa3053928f0193f5ddbb360 /src/eval.c
parentf21dc38a6ed3851a5e6501199e803ff0b93795cf (diff)
downloadredis-cbd463175f8b52d594fd4e6b953fa58a5db053c3.tar.gz
Redis Functions - Added redis function unit and Lua engine
Redis function unit is located inside functions.c and contains Redis Function implementation: 1. FUNCTION commands: * FUNCTION CREATE * FCALL * FCALL_RO * FUNCTION DELETE * FUNCTION KILL * FUNCTION INFO 2. Register engine In addition, this commit introduce the first engine that uses the Redis Function capabilities, the Lua engine.
Diffstat (limited to 'src/eval.c')
-rw-r--r--src/eval.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/eval.c b/src/eval.c
index f8fe8bf37..977cad721 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -257,7 +257,7 @@ void scriptingInit(int setup) {
/* Lua beginners often don't use "local", this is likely to introduce
* subtle bugs in their code. To prevent problems we protect accesses
* to global variables. */
- luaEnableGlobalsProtection(lua);
+ luaEnableGlobalsProtection(lua, 1);
lctx.lua = lua;
}
@@ -443,6 +443,8 @@ void evalGenericCommand(client *c, int evalsha) {
scriptRunCtx rctx;
scriptPrepareForRun(&rctx, lctx.lua_client, c, lctx.lua_cur_script);
+ rctx.flags |= SCRIPT_EVAL_MODE; /* mark the current run as legacy so we
+ will get legacy error messages and logs */
if (!lctx.lua_replicate_commands) rctx.flags |= SCRIPT_EVAL_REPLICATION;
/* This check is for EVAL_RO, EVALSHA_RO. We want to allow only read only commands */
if ((server.script_caller->cmd->proc == evalRoCommand ||
@@ -584,7 +586,7 @@ NULL
addReplyBulkCBuffer(c,sha,40);
forceCommandPropagation(c,PROPAGATE_REPL|PROPAGATE_AOF);
} else if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"kill")) {
- scriptKill(c);
+ scriptKill(c, 1);
} else if (c->argc == 3 && !strcasecmp(c->argv[1]->ptr,"debug")) {
if (clientHasPendingReplies(c)) {
addReplyError(c,"SCRIPT DEBUG must be called outside a pipeline");
@@ -610,7 +612,7 @@ NULL
}
unsigned long evalMemory() {
- return lua_gc(lctx.lua, LUA_GCCOUNT, 0) * 1024LL;
+ return luaMemory(lctx.lua);
}
dict* evalScriptsDict() {