mirror of
https://github.com/fluencelabs/redis
synced 2025-03-17 16:10:50 +00:00
Lua scripting: Honor SELECT command in both ways
This commit is contained in:
parent
09ab5591fa
commit
c2a7dd85ae
@ -368,15 +368,20 @@ void evalCommand(redisClient *c) {
|
||||
* EVAL received. */
|
||||
luaSetGlobalArray(lua,"KEYS",c->argv+3,numkeys);
|
||||
luaSetGlobalArray(lua,"ARGV",c->argv+3+numkeys,c->argc-3-numkeys);
|
||||
|
||||
/* Select the right DB in the context of the Lua client */
|
||||
selectDb(server.lua_client,c->db->id);
|
||||
|
||||
/* At this point whatever this script was never seen before or if it was
|
||||
* already defined, we can call it. We have zero arguments and expect
|
||||
* a single return value. */
|
||||
if (lua_pcall(lua,0,1,0)) {
|
||||
selectDb(c,server.lua_client->db->id); /* set DB ID from Lua client */
|
||||
addReplyErrorFormat(c,"Error running script (call to %s): %s\n",
|
||||
funcname, lua_tostring(lua,-1));
|
||||
lua_pop(lua,1);
|
||||
return;
|
||||
}
|
||||
selectDb(c,server.lua_client->db->id); /* set DB ID from Lua client */
|
||||
luaReplyToRedisReply(c,lua);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user