mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2024-12-14 11:58:02 +00:00
feat(server family): reject flushall and flushdb on multi command (#657)
* feat(server family): reject flushall and flushdb on multi command Signed-off-by: adi_holden <adi@dragonflydb.io>
This commit is contained in:
parent
1fa5340c27
commit
53f3d860db
2 changed files with 14 additions and 4 deletions
|
@ -101,6 +101,16 @@ TEST_F(DflyEngineTest, MultiAndEval) {
|
|||
"transaction block"));
|
||||
}
|
||||
|
||||
TEST_F(DflyEngineTest, MultiAndFlush) {
|
||||
RespExpr resp = Run({"multi"});
|
||||
ASSERT_EQ(resp, "OK");
|
||||
|
||||
resp = Run({"get", kKey1});
|
||||
ASSERT_EQ(resp, "QUEUED");
|
||||
|
||||
EXPECT_THAT(Run({"FLUSHALL"}), ErrArg("'FLUSHALL' inside MULTI is not allowed"));
|
||||
}
|
||||
|
||||
TEST_F(DflyEngineTest, Multi) {
|
||||
RespExpr resp = Run({"multi"});
|
||||
ASSERT_EQ(resp, "OK");
|
||||
|
@ -650,7 +660,7 @@ TEST_F(DflyEngineTest, Watch) {
|
|||
|
||||
// Check watch doesn't run in multi.
|
||||
Run({"multi"});
|
||||
ASSERT_THAT(Run({"watch", "a"}), ErrArg("WATCH inside MULTI is not allowed"));
|
||||
ASSERT_THAT(Run({"watch", "a"}), ErrArg("'WATCH' inside MULTI is not allowed"));
|
||||
Run({"discard"});
|
||||
|
||||
// Check watch on existing key.
|
||||
|
|
|
@ -606,9 +606,9 @@ void Service::DispatchCommand(CmdArgList args, facade::ConnectionContext* cntx)
|
|||
return;
|
||||
}
|
||||
|
||||
if (cmd_name == "WATCH") {
|
||||
(*cntx)->SendError("WATCH inside MULTI is not allowed");
|
||||
return;
|
||||
if (cmd_name == "WATCH" || cmd_name == "FLUSHALL" || cmd_name == "FLUSHDB") {
|
||||
auto error = absl::StrCat("'", cmd_name, "' inside MULTI is not allowed");
|
||||
return (*cntx)->SendError(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue