diff --git a/src/commands.def b/src/commands.def index 99f4872f0e..4559c0aefe 100644 --- a/src/commands.def +++ b/src/commands.def @@ -11022,8 +11022,8 @@ struct COMMAND_STRUCT serverCommandTable[] = { /* transactions */ {MAKE_CMD("discard","Discards a transaction.","O(N), when N is the number of queued commands","2.0.0",CMD_DOC_NONE,NULL,NULL,"transactions",COMMAND_GROUP_TRANSACTIONS,DISCARD_History,0,DISCARD_Tips,0,discardCommand,1,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_FAST|CMD_ALLOW_BUSY,ACL_CATEGORY_TRANSACTION,DISCARD_Keyspecs,0,NULL,0)}, {MAKE_CMD("exec","Executes all commands in a transaction.","Depends on commands in the transaction","1.2.0",CMD_DOC_NONE,NULL,NULL,"transactions",COMMAND_GROUP_TRANSACTIONS,EXEC_History,0,EXEC_Tips,0,execCommand,1,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SKIP_SLOWLOG,ACL_CATEGORY_TRANSACTION,EXEC_Keyspecs,0,NULL,0)}, -{MAKE_CMD("multi","Starts a transaction.","O(1)","1.2.0",CMD_DOC_NONE,NULL,NULL,"transactions",COMMAND_GROUP_TRANSACTIONS,MULTI_History,0,MULTI_Tips,0,multiCommand,1,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_FAST|CMD_ALLOW_BUSY,ACL_CATEGORY_TRANSACTION,MULTI_Keyspecs,0,NULL,0)}, +{MAKE_CMD("multi","Starts a transaction.","O(1)","1.2.0",CMD_DOC_NONE,NULL,NULL,"transactions",COMMAND_GROUP_TRANSACTIONS,MULTI_History,0,MULTI_Tips,0,multiCommand,1,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_FAST|CMD_NO_MULTI|CMD_ALLOW_BUSY,ACL_CATEGORY_TRANSACTION,MULTI_Keyspecs,0,NULL,0)}, {MAKE_CMD("unwatch","Forgets about watched keys of a transaction.","O(1)","2.2.0",CMD_DOC_NONE,NULL,NULL,"transactions",COMMAND_GROUP_TRANSACTIONS,UNWATCH_History,0,UNWATCH_Tips,0,unwatchCommand,1,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_FAST|CMD_ALLOW_BUSY,ACL_CATEGORY_TRANSACTION,UNWATCH_Keyspecs,0,NULL,0)}, -{MAKE_CMD("watch","Monitors changes to keys to determine the execution of a transaction.","O(1) for every key.","2.2.0",CMD_DOC_NONE,NULL,NULL,"transactions",COMMAND_GROUP_TRANSACTIONS,WATCH_History,0,WATCH_Tips,0,watchCommand,-2,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_FAST|CMD_ALLOW_BUSY,ACL_CATEGORY_TRANSACTION,WATCH_Keyspecs,1,NULL,1),.args=WATCH_Args}, +{MAKE_CMD("watch","Monitors changes to keys to determine the execution of a transaction.","O(1) for every key.","2.2.0",CMD_DOC_NONE,NULL,NULL,"transactions",COMMAND_GROUP_TRANSACTIONS,WATCH_History,0,WATCH_Tips,0,watchCommand,-2,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_FAST|CMD_NO_MULTI|CMD_ALLOW_BUSY,ACL_CATEGORY_TRANSACTION,WATCH_Keyspecs,1,NULL,1),.args=WATCH_Args}, {0} }; diff --git a/src/commands/multi.json b/src/commands/multi.json index 5f17a1da29..e66fff0174 100644 --- a/src/commands/multi.json +++ b/src/commands/multi.json @@ -11,6 +11,7 @@ "LOADING", "STALE", "FAST", + "NO_MULTI", "ALLOW_BUSY" ], "acl_categories": [ diff --git a/src/commands/watch.json b/src/commands/watch.json index 9faab2b917..588cea72b4 100644 --- a/src/commands/watch.json +++ b/src/commands/watch.json @@ -11,6 +11,7 @@ "LOADING", "STALE", "FAST", + "NO_MULTI", "ALLOW_BUSY" ], "acl_categories": [ diff --git a/src/multi.c b/src/multi.c index 24311c9982..074060269c 100644 --- a/src/multi.c +++ b/src/multi.c @@ -109,12 +109,7 @@ void flagTransaction(client *c) { } void multiCommand(client *c) { - if (c->flag.multi) { - addReplyError(c, "MULTI calls can not be nested"); - return; - } c->flag.multi = 1; - addReply(c, shared.ok); } @@ -459,10 +454,6 @@ void touchAllWatchedKeysInDb(serverDb *emptied, serverDb *replaced_with) { void watchCommand(client *c) { int j; - if (c->flag.multi) { - addReplyError(c, "WATCH inside MULTI is not allowed"); - return; - } /* No point in watching if the client is already dirty. */ if (c->flag.dirty_cas) { addReply(c, shared.ok); diff --git a/tests/unit/multi.tcl b/tests/unit/multi.tcl index 0e2e74c2b6..dafbc66c10 100644 --- a/tests/unit/multi.tcl +++ b/tests/unit/multi.tcl @@ -34,12 +34,10 @@ start_server {tags {"multi"}} { } {QUEUED OK {a b c}} test {Nested MULTI are not allowed} { - set err {} r multi - catch {[r multi]} err - r exec - set _ $err - } {*ERR MULTI*} + assert_error "ERR*" {r multi} + assert_error "EXECABORT*" {r exec} + } test {MULTI where commands alter argc/argv} { r sadd myset a @@ -49,12 +47,10 @@ start_server {tags {"multi"}} { } {a 0} test {WATCH inside MULTI is not allowed} { - set err {} r multi - catch {[r watch x]} err - r exec - set _ $err - } {*ERR WATCH*} + assert_error "ERR*" {r watch} + assert_error "EXECABORT*" {r exec} + } test {EXEC fails if there are errors while queueing commands #1} { r del foo1{t} foo2{t}