Make dbid range check for SWAPDB command consistent with SELECT, MOVE, and COPY. (#8555)
DB ID used to be parsed as a long for SWAPDB command, now make it into an int to be consistent with other commands that parses the DB ID argument like SELECT, MOVE, COPY. See #8085 The implication is that the error message when the provided db index is greater than 4M changes slightly.
This commit is contained in:
parent
18ff8cd1fb
commit
a66814fd7a
8
src/db.c
8
src/db.c
@ -1315,7 +1315,7 @@ void scanDatabaseForReadyLists(redisDb *db) {
|
|||||||
*
|
*
|
||||||
* Returns C_ERR if at least one of the DB ids are out of range, otherwise
|
* Returns C_ERR if at least one of the DB ids are out of range, otherwise
|
||||||
* C_OK is returned. */
|
* C_OK is returned. */
|
||||||
int dbSwapDatabases(long id1, long id2) {
|
int dbSwapDatabases(int id1, int id2) {
|
||||||
if (id1 < 0 || id1 >= server.dbnum ||
|
if (id1 < 0 || id1 >= server.dbnum ||
|
||||||
id2 < 0 || id2 >= server.dbnum) return C_ERR;
|
id2 < 0 || id2 >= server.dbnum) return C_ERR;
|
||||||
if (id1 == id2) return C_OK;
|
if (id1 == id2) return C_OK;
|
||||||
@ -1356,7 +1356,7 @@ int dbSwapDatabases(long id1, long id2) {
|
|||||||
|
|
||||||
/* SWAPDB db1 db2 */
|
/* SWAPDB db1 db2 */
|
||||||
void swapdbCommand(client *c) {
|
void swapdbCommand(client *c) {
|
||||||
long id1, id2;
|
int id1, id2;
|
||||||
|
|
||||||
/* Not allowed in cluster mode: we have just DB 0 there. */
|
/* Not allowed in cluster mode: we have just DB 0 there. */
|
||||||
if (server.cluster_enabled) {
|
if (server.cluster_enabled) {
|
||||||
@ -1365,11 +1365,11 @@ void swapdbCommand(client *c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Get the two DBs indexes. */
|
/* Get the two DBs indexes. */
|
||||||
if (getLongFromObjectOrReply(c, c->argv[1], &id1,
|
if (getIntFromObjectOrReply(c, c->argv[1], &id1,
|
||||||
"invalid first DB index") != C_OK)
|
"invalid first DB index") != C_OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (getLongFromObjectOrReply(c, c->argv[2], &id2,
|
if (getIntFromObjectOrReply(c, c->argv[2], &id2,
|
||||||
"invalid second DB index") != C_OK)
|
"invalid second DB index") != C_OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user