From ce4bacdaff26f7eb5bff58c3bc5be6a1742a60d4 Mon Sep 17 00:00:00 2001 From: PragmaTwice Date: Fri, 10 Mar 2023 23:06:47 +0800 Subject: [PATCH] fix script exists --- src/server/server.cc | 7 +++++++ src/storage/scripting.cc | 4 ++-- src/storage/scripting.h | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/server/server.cc b/src/server/server.cc index d2d8209d9e1..55ee5303f46 100644 --- a/src/server/server.cc +++ b/src/server/server.cc @@ -36,6 +36,7 @@ #include "commands/commander.h" #include "config.h" #include "fmt/format.h" +#include "lua.h" #include "redis_connection.h" #include "redis_request.h" #include "storage/compaction_checker.h" @@ -1498,6 +1499,12 @@ Status Server::LookupAndCreateCommand(const std::string &cmd_name, std::unique_p } Status Server::ScriptExists(const std::string &sha) { + lua_getglobal(lua_, (REDIS_LUA_FUNC_SHA_PREFIX + sha).c_str()); + if (!lua_isnil(lua_, -1)) { + return Status::OK(); + } + lua_pop(lua_, 1); + std::string body; return ScriptGet(sha, &body); } diff --git a/src/storage/scripting.cc b/src/storage/scripting.cc index 17fc23012dc..e1aa723364c 100644 --- a/src/storage/scripting.cc +++ b/src/storage/scripting.cc @@ -220,7 +220,7 @@ Status evalGenericCommand(Redis::Connection *conn, const std::vector