Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
c2a7dd85
Commit
c2a7dd85
authored
May 03, 2011
by
antirez
Browse files
Lua scripting: Honor SELECT command in both ways
parent
09ab5591
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/scripting.c
View file @
c2a7dd85
...
...
@@ -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
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment