]> git.saurik.com Git - redis.git/commitdiff
Restore argc/argv in EXEC after command is executed
authorPieter Noordhuis <pcnoordhuis@gmail.com>
Wed, 23 Feb 2011 08:39:29 +0000 (09:39 +0100)
committerantirez <antirez@gmail.com>
Wed, 23 Feb 2011 13:37:22 +0000 (14:37 +0100)
src/multi.c
tests/unit/other.tcl

index 59fc9d9e8b80f16c649704147af18dcb68f86049..ba3a0cd6caaa0cf96e7fdb883ee0f1ad902efdbb 100644 (file)
@@ -110,6 +110,10 @@ void execCommand(redisClient *c) {
         c->argc = c->mstate.commands[j].argc;
         c->argv = c->mstate.commands[j].argv;
         call(c,c->mstate.commands[j].cmd);
         c->argc = c->mstate.commands[j].argc;
         c->argv = c->mstate.commands[j].argv;
         call(c,c->mstate.commands[j].cmd);
+
+        /* Commands may alter argc/argv, restore mstate. */
+        c->mstate.commands[j].argc = c->argc;
+        c->mstate.commands[j].argv = c->argv;
     }
     c->argv = orig_argv;
     c->argc = orig_argc;
     }
     c->argv = orig_argv;
     c->argc = orig_argc;
index f30505d102d276c586679e04dc8fc7c6304fdbde..716d6897af6318eb6f0239942cb0deb2030af69e 100644 (file)
@@ -183,6 +183,13 @@ start_server {tags {"other"}} {
         set _ $err
     } {*ERR MULTI*}
 
         set _ $err
     } {*ERR MULTI*}
 
+    test {MULTI where commands alter argc/argv} {
+        r sadd myset a
+        r multi
+        r spop myset
+        list [r exec] [r exists myset]
+    } {a 0}
+
     test {WATCH inside MULTI is not allowed} {
         set err {}
         r multi
     test {WATCH inside MULTI is not allowed} {
         set err {}
         r multi