From 6931004969d23dc6233a94e422090f35ebec143d Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 16 Sep 2019 18:18:17 +0200 Subject: [PATCH] RESP3: change behavior of Lua returning true/false for RESP3. Here we introduce a change in the way we convert values from Lua to Redis when RESP3 is selected: this is possible without breaking the fact we can return directly what a command returned, because there is no Redis command in RESP2 that returns true or false to Lua, so the conversion in the case of RESP2 is totally arbitrary. When a script is written selecting RESP3 from Lua, it totally makes sense to change such behavior and return RESP3 true/false when Lua true/false is returned. --- src/scripting.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/scripting.c b/src/scripting.c index 564dad8ca..3ad228a67 100644 --- a/src/scripting.c +++ b/src/scripting.c @@ -315,7 +315,11 @@ void luaReplyToRedisReply(client *c, lua_State *lua) { addReplyBulkCBuffer(c,(char*)lua_tostring(lua,-1),lua_strlen(lua,-1)); break; case LUA_TBOOLEAN: - addReply(c,lua_toboolean(lua,-1) ? shared.cone : shared.null[c->resp]); + if (server.lua_client->resp == 2) + addReply(c,lua_toboolean(lua,-1) ? shared.cone : + shared.null[c->resp]); + else + addReplyBool(c,lua_toboolean(lua,-1)); break; case LUA_TNUMBER: addReplyLongLong(c,(long long)lua_tonumber(lua,-1));