SWAPDB db1 db2 */
| 1365 | |
| 1366 | /* SWAPDB db1 db2 */ |
| 1367 | void swapdbCommand(client *c) { |
| 1368 | int id1, id2; |
| 1369 | |
| 1370 | /* Not allowed in cluster mode: we have just DB 0 there. */ |
| 1371 | if (server.cluster_enabled) { |
| 1372 | addReplyError(c,"SWAPDB is not allowed in cluster mode"); |
| 1373 | return; |
| 1374 | } |
| 1375 | |
| 1376 | /* Get the two DBs indexes. */ |
| 1377 | if (getIntFromObjectOrReply(c, c->argv[1], &id1, |
| 1378 | "invalid first DB index") != C_OK) |
| 1379 | return; |
| 1380 | |
| 1381 | if (getIntFromObjectOrReply(c, c->argv[2], &id2, |
| 1382 | "invalid second DB index") != C_OK) |
| 1383 | return; |
| 1384 | |
| 1385 | /* Swap... */ |
| 1386 | if (dbSwapDatabases(id1,id2) == C_ERR) { |
| 1387 | addReplyError(c,"DB index is out of range"); |
| 1388 | return; |
| 1389 | } else { |
| 1390 | RedisModuleSwapDbInfo si = {REDISMODULE_SWAPDBINFO_VERSION,id1,id2}; |
| 1391 | moduleFireServerEvent(REDISMODULE_EVENT_SWAPDB,0,&si); |
| 1392 | server.dirty++; |
| 1393 | addReply(c,shared.ok); |
| 1394 | } |
| 1395 | } |
| 1396 | |
| 1397 | /*----------------------------------------------------------------------------- |
| 1398 | * Expires API |
nothing calls this directly
no test coverage detected