Skip to content

Commit

Permalink
Make client subcommands not case sensitive (apache#361)
Browse files Browse the repository at this point in the history
Before, client subcommands must be lower cases, otherwise kvrocks will fail to execute,
so sentinel still can't failover, related to apache#352
  • Loading branch information
ShooterIT committed Sep 10, 2021
1 parent 7a5e50a commit 55afeea
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
21 changes: 11 additions & 10 deletions src/redis_cmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3575,30 +3575,31 @@ class CommandClient : public Commander {
new_format_ = true;
while (i < args.size()) {
bool moreargs = i < args.size();
if (args[i] == "addr" && moreargs) {
if (!strcasecmp(args[i].c_str(), "addr") && moreargs) {
addr_ = args[i+1];
} else if (args[i] == "id" && moreargs) {
} else if (!strcasecmp(args[i].c_str(), "id") && moreargs) {
try {
id_ = std::stoll(args[i+1]);
} catch (std::exception &e) {
return Status(Status::RedisParseErr, errValueNotInterger);
}
} else if (args[i] == "skipme" && moreargs) {
if (args[i+1] == "yes") {
} else if (!strcasecmp(args[i].c_str(), "skipme") && moreargs) {
if (!strcasecmp(args[i+1].c_str(), "yes")) {
skipme_ = true;
} else if (args[i+1] == "no") {
} else if (!strcasecmp(args[i+1].c_str(), "no")) {
skipme_ = false;
} else {
return Status(Status::RedisParseErr, errInvalidSyntax);
}
} else if (args[i] == "type" && moreargs) {
if (args[i+1] == "normal") {
} else if (!strcasecmp(args[i].c_str(), "type") && moreargs) {
if (!strcasecmp(args[i+1].c_str(), "normal")) {
kill_type_ |= kTypeNormal;
} else if (args[i+1] == "pubsub") {
} else if (!strcasecmp(args[i+1].c_str(), "pubsub")) {
kill_type_ |= kTypePubsub;
} else if (args[i+1] == "master") {
} else if (!strcasecmp(args[i+1].c_str(), "master")) {
kill_type_ |= kTypeMaster;
} else if (args[i+1] == "replica" || args[i+1] == "slave") {
} else if (!strcasecmp(args[i+1].c_str(), "replica") ||
!strcasecmp(args[i+1].c_str(), "slave")) {
kill_type_ |= kTypeSlave;
} else {
return Status(Status::RedisParseErr, errInvalidSyntax);
Expand Down
24 changes: 12 additions & 12 deletions tests/tcl/tests/unit/multi.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,21 @@ start_server {tags {"multi"}} {

test {MULTI-EXEC used in redis-sentinel for failover} {
start_server {} {
r multi
r slaveof [srv -1 host] [srv -1 port]
r config rewrite
r client kill type normal
r client kill type pubsub
r exec
r MULTI
r SLAVEOF [srv -1 host] [srv -1 port]
r CONFIG REWRITE
r CLIENT KILL TYPE normal
r CLIENT KILL TYPE PUBSUB
r EXEC
reconnect
assert_equal "slave" [s role]

r multi
r slaveof no one
r config rewrite
r client kill type normal
r client kill type pubsub
r exec
r MULTI
r SLAVEOF NO ONE
r CONFIG REWRITE
r CLIENT kill TYPE NORMAL
r client KILL type pubsub
r EXEC
reconnect
assert_equal "master" [s role]
}
Expand Down

0 comments on commit 55afeea

Please sign in to comment.