Commit a7b058da authored by antirez's avatar antirez
Browse files

Fixed semantics of CLUSTER SETSLOT, SELECT now only denied in cluster mode if...

Fixed semantics of CLUSTER SETSLOT, SELECT now only denied in cluster mode if selected DB is not 0 so that MIGRATE still works well.
parent 46834808
...@@ -1219,11 +1219,11 @@ void clusterCommand(redisClient *c) { ...@@ -1219,11 +1219,11 @@ void clusterCommand(redisClient *c) {
return; return;
} }
slot = (unsigned int) aux; slot = (unsigned int) aux;
if (server.cluster.slots[slot] != server.cluster.myself) {
addReplyErrorFormat(c,"I'm not the owner of hash slot %u",slot);
return;
}
if (!strcasecmp(c->argv[3]->ptr,"migrating") && c->argc == 5) { if (!strcasecmp(c->argv[3]->ptr,"migrating") && c->argc == 5) {
if (server.cluster.slots[slot] != server.cluster.myself) {
addReplyErrorFormat(c,"I'm not the owner of hash slot %u",slot);
return;
}
if ((n = clusterLookupNode(c->argv[4]->ptr)) == NULL) { if ((n = clusterLookupNode(c->argv[4]->ptr)) == NULL) {
addReplyErrorFormat(c,"I don't know about node %s", addReplyErrorFormat(c,"I don't know about node %s",
(char*)c->argv[4]->ptr); (char*)c->argv[4]->ptr);
...@@ -1231,6 +1231,11 @@ void clusterCommand(redisClient *c) { ...@@ -1231,6 +1231,11 @@ void clusterCommand(redisClient *c) {
} }
server.cluster.migrating_slots_to[slot] = n; server.cluster.migrating_slots_to[slot] = n;
} else if (!strcasecmp(c->argv[3]->ptr,"importing") && c->argc == 5) { } else if (!strcasecmp(c->argv[3]->ptr,"importing") && c->argc == 5) {
if (server.cluster.slots[slot] == server.cluster.myself) {
addReplyErrorFormat(c,
"I'm already the owner of hash slot %u",slot);
return;
}
if ((n = clusterLookupNode(c->argv[4]->ptr)) == NULL) { if ((n = clusterLookupNode(c->argv[4]->ptr)) == NULL) {
addReplyErrorFormat(c,"I don't know about node %s", addReplyErrorFormat(c,"I don't know about node %s",
(char*)c->argv[3]->ptr); (char*)c->argv[3]->ptr);
......
...@@ -317,7 +317,7 @@ void existsCommand(redisClient *c) { ...@@ -317,7 +317,7 @@ void existsCommand(redisClient *c) {
void selectCommand(redisClient *c) { void selectCommand(redisClient *c) {
int id = atoi(c->argv[1]->ptr); int id = atoi(c->argv[1]->ptr);
if (server.cluster_enabled) { if (server.cluster_enabled && id != 0) {
addReplyError(c,"SELECT is not allowed in cluster mode"); addReplyError(c,"SELECT is not allowed in cluster mode");
return; return;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment